Page 1 of 1

unzip: 'error: cannot create file' after upload

Posted: Sat Jul 08, 2006 2:21 pm
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

Posted: Wed Jul 12, 2006 12:14 am
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?