unzip: 'error: cannot create file' after upload

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

unzip: 'error: cannot create file' after upload

Post by Skara »

Er.. dunno if this would go in the linux forum or here. In any case...

Code: Select all

$zname = basename($_FILES['file']['name']);
$destf = BASEDIR.'photos/'.$ndir;  //BASEDIR = /var/www/localhost/htdocs/
mkdir($destf,0777);
$dest = $destf.'/'.$zname;
if (!move_uploaded_file($_FILES['file']['tmp_name'], $dest)) return 'Error moving uploaded file.';
chmod($dest,0666); //do I need this?

chdir($destf);
shell_exec("unzip $dest &>info/unzip.info");
chdir('../..'.ADMIN_CP); //back to where it was
I get the following output from unzip.info: (8 is $ndir)
Archive: /var/www/localhost/htdocs/photos/8/1234.zip
error: cannot create file1.jpg
error: cannot create ...

Permissions are:
photos: 777
$ndir: 777
uploaded.zip: 666
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Have you tried running it over ssh? It's not just the folder that needs permissions set. Sometimes the entire path needs to have proper permissions set. In this case unzip would be running as nobody I believe, and nobody might not have access to /var/www/etc...

You ever get it fixed?
Post Reply