Forum Moderators: coopster

Message Too Old, No Replies

Creating ZIP files using Perl inside a PHP file

Create ZIP file using Perl inside php

         

Nurples

1:49 am on Mar 24, 2010 (gmt 0)

10+ Year Member



Hello,
I've never used Perl scripts before and I need a little help. I'm building a site in PHP that will allow users to select images. I need the selected images to be added to a zip file. I can't use the PHP Zip functions as I can't get the ZZIPlib libary installed on the server. I do believe I can use Perl to create a zip file with the selected files.

Problem I have is that I don't understand how to add perl codes to my PHP file as I've never used them. Could someone please give me a short and simple (if possible) explination on how to do this?

rocknbil

2:50 am on Mar 24, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard Nurples, run an exec() [us.php.net] or system() [us.php.net] command on the Perl file? Be sure to chmod the perl file to 755, it needs to be executable.

Nurples

10:08 am on Mar 24, 2010 (gmt 0)

10+ Year Member



Thanks, I'll give that a shot. Part of my problem may be that the file permissions are not 755. :)

rocknbil

6:41 pm on Mar 24, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yeah, it's different with perl. Another possible challenge you may encounter, some servers don't allow execution of perl "just anywhere" like PHP. It may need to be in the cgi-bin directory, a restricted location for executable scripts.

When referring to a script via exec/system, be aware it's not the same as a URL. Example,

document root: /var/www/example.com/httpdocs

/cgi-bin/test.cgi
script.php
/directory/executed-from-here.php

**sometimes** it's OK to execute test.cgi from executed-from-here.php like

exec('../cgi-bin/test.cgi');

Calling that script from the web will be fine with the same link, but if you're in the (good, IMO) habit of using domain relative links in your pages,

/cgi-bin/test.cgi

when put in an exec/system command, this will attempt to access the script from /var in the example above. So the most portable method might be

exec($_SERVER['DOCUMENT_ROOT'].'/cgi-bin/test.cgi');

coopster

8:08 pm on Mar 24, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I may be off base here but if the zip library is not installed then perl won't be an answer either.