phpSensei Posted December 12, 2007 Share Posted December 12, 2007 Is there any way to create a directory using mkdir();, then ZIP the folder? edit: I am sorry, I meant how do you make convert folders to .zip in a directory. Quote Link to comment Share on other sites More sharing options...
revraz Posted December 12, 2007 Share Posted December 12, 2007 Zip what file? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 12, 2007 Author Share Posted December 12, 2007 my question was pretty straight forward, I just typed in FILE instead of FOLDER in the topic title. How do you convert a normal folder in a directory to a .zip folder? Quote Link to comment Share on other sites More sharing options...
mr_mind Posted December 12, 2007 Share Posted December 12, 2007 $filename = 'textfile.txt'; if(exec("bzip2 " . $filename)) { print 'file zippped'; } else{ print 'failed'; } Quote Link to comment Share on other sites More sharing options...
revraz Posted December 12, 2007 Share Posted December 12, 2007 Your question asked how you .zip a file, yet you didn't mention anything but making a folder. You don't convert a folder to a zip folder, you execute a zip a zip function to create a zip file. If you have that feature available when you installed PHP. http://us3.php.net/zip Quote Link to comment Share on other sites More sharing options...
mr_mind Posted December 12, 2007 Share Posted December 12, 2007 youdont need the feature available just run an exec command like i posted above Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 12, 2007 Author Share Posted December 12, 2007 I was being an idiot, I am really tired and stressed out, and I really didn't realise what questions I was asking for. I thankyou you all for your help, I got it going. again, im sorry. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 12, 2007 Author Share Posted December 12, 2007 $filename = 'textfile.txt'; if(exec("bzip2 " . $filename)) { print 'file zippped'; } else{ print 'failed'; } Did not work. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 12, 2007 Author Share Posted December 12, 2007 Alright, my last topic didnt make sense so here I go again. I have a folder called "v1" on my server. Now how do i compress that folder into a ZIP archieve? I looked into zip functions on php.net and nothing goes about creating zipped folders. Help. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 12, 2007 Author Share Posted December 12, 2007 bumb Quote Link to comment Share on other sites More sharing options...
trq Posted December 12, 2007 Share Posted December 12, 2007 Providing your on a Linux server.... [code] <?php exec('/usr/biun/zip -r v1 v1'); ?> ought do the trick. You'll get greater compression out of tar though.[/code] Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 12, 2007 Author Share Posted December 12, 2007 Providing your on a Linux server.... [code] <?php exec('/usr/biun/zip -r v1 v1'); ?> ought do the trick. You'll get greater compression out of tar though.[/code] Where do i provide the folder name? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 13, 2007 Author Share Posted December 13, 2007 Ah. I see where it says V1 in there, thankyou i will try it out and let you know if it worked. edit: Dont you mean/bin/ instead of /biun/ Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 13, 2007 Author Share Posted December 13, 2007 It didnt work. Quote Link to comment Share on other sites More sharing options...
mr_mind Posted December 13, 2007 Share Posted December 13, 2007 Providing your on a Linux server.... [code] <?php exec('/usr/biun/zip -r v1 v1'); ?> ought do the trick. You'll get greater compression out of tar though.[/code] it is /usr/bin/zip not /usr/biun/zip Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 13, 2007 Author Share Posted December 13, 2007 This script really doesnt do anything to the "v1" folder at all. Thankyou all for your help, I will try to figure this out. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 13, 2007 Author Share Posted December 13, 2007 bump. doesnt work. Quote Link to comment Share on other sites More sharing options...
mr_mind Posted December 14, 2007 Share Posted December 14, 2007 Are you using L.A.M.P or W.A.M.P? What zip program do you have installed on the server? What php version do you have running. If you are using L.A.M.P what linux distribution are you using? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Author Share Posted December 14, 2007 I am using the latest version of W.A.M.P. I even tried it on my server at www.flash-portal.org/fp-quick/zip.php "boo" - means it didnt work "Worked" - well...y'know Quote Link to comment Share on other sites More sharing options...
trq Posted December 14, 2007 Share Posted December 14, 2007 As my post said.... Provided your using a Linux server... Is your host Linux? If so, what is the output of? <?php echo system('whereis zip'); ?> Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Author Share Posted December 14, 2007 Thorpe, the script you gave me outputs nothing... I don't think I am on a Linux server Quote Link to comment Share on other sites More sharing options...
trq Posted December 14, 2007 Share Posted December 14, 2007 Have you checked phpinfo() to see if you have the zip extension installed? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Author Share Posted December 14, 2007 Have you checked phpinfo() to see if you have the zip extension installed? PHP Version 5.2.5 - PHPinfo http://localhost/hah/zip.php If i dont, how do I install it, or enable this function? zlib.output_compression Off Off I never understood these things, and how to install some like zlib http://www.zlib.net/ Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Author Share Posted December 14, 2007 I enabled it zlib.output_compression On Off Quote Link to comment Share on other sites More sharing options...
trq Posted December 14, 2007 Share Posted December 14, 2007 PHP Version 5.2.5 - PHPinfo http://localhost/hah/zip.php http://localhost is only relative to your machine, no one else can see it!!! If i dont, how do I install it, or enable this function? Are you on shared hosting? Ask your host, otherwise, see the manual and follow the instructions. I enabled it zlib.output_compression On Off Output compression has nothing to do with the zip extension. Secondly, if you did want to enable that you would use.... zlib.output_compression On Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.