+ Reply to Thread
Results 1 to 6 of 6

Thread: exec() in PHP to create zip archives.

  1. #1
    scc123 is offline x10Hosting Member scc123 is an unknown quantity at this point
    Join Date
    Feb 2009
    Posts
    18

    exec() in PHP to create zip archives.

    I have a user front end for a file hosting type website (not hosted here) and I need to be able to let my users create zip archives and download them on the fly of their areas.

    PHP Code:
    $usnses=$_SESSION['username'];
    exec('zip /users/'.$usnses.'/smwfiles.zip /users/'.$usnses.'/'); 
    Is what I am using at the minute but every archive is just empty =/
    Any help?
    Thanks

    EDIT:
    Never mind I done it
    PHP Code:
    exec("zip -r $f ./users/".$usnses."/*.html"); 
    Last edited by scc123; 02-22-2010 at 07:08 AM.

  2. #2
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: exec() in PHP to create zip archives.


  3. #3
    scc123 is offline x10Hosting Member scc123 is an unknown quantity at this point
    Join Date
    Feb 2009
    Posts
    18

    Re: exec() in PHP to create zip archives.

    Eh I managed to get it done on one line
    Thanks anyway.

  4. #4
    misson is offline Community Advocate misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,391

    Re: exec() in PHP to create zip archives.

    Just be careful of injection attacks.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    scc123 is offline x10Hosting Member scc123 is an unknown quantity at this point
    Join Date
    Feb 2009
    Posts
    18

    Re: exec() in PHP to create zip archives.

    PHP Code:
    $f=escapeshellarg(escapeshellcmd(clean($f)));
    $usnses=escapeshellarg(escapeshellcmd(clean($usnses))); 
    Not to take any chances

  6. #6
    xav0989's Avatar
    xav0989 is offline Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,410

    Re: exec() in PHP to create zip archives.

    I would not recommend using exec as some hosts might disable it.
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

+ Reply to Thread

Similar Threads

  1. Ever Been Suspended For Using PHP?
    By dragoneye_xp in forum Off Topic
    Replies: 26
    Last Post: 08-16-2009, 08:17 PM
  2. 1000 credits to create this php script
    By warlordste in forum The Marketplace
    Replies: 3
    Last Post: 02-26-2009, 09:36 PM
  3. phpMyAdmin not allowing create php code
    By Calystos in forum Free Hosting
    Replies: 2
    Last Post: 11-25-2008, 03:07 AM
  4. Request for Advance PHP Config
    By crownabhisek in forum Free Hosting
    Replies: 5
    Last Post: 05-28-2008, 07:41 AM
  5. Create image in PHP
    By alfred in forum Tutorials
    Replies: 2
    Last Post: 10-21-2007, 11:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers