So, I'm trying to create a bulk upload function, when a user can upload a single ZIP file containing a bunch of PDF files, which will then be processed and saved on the server, etc.
While I have it ...
$serverpath = $_SERVER['DOCUMENT_ROOT'];
if(array_key_exists('bulk_filename', $_FILES)){
if ($_FILES['bulk_filename']['error'] === UPLOAD_ERR_OK) {
$file_name = $_FILES['bulk_filename']['name'];
$new_zip_file = $serverpath . '/customerdata/tmp_invoices/' . $file_name;
move_uploaded_file($_FILES['bulk_filename']['tmp_name'], $new_zip_file);
exec('chmod -R 755 ' . $serverpath . '/customerdata/tmp_invoices/' . $file_name);
$zip = new ZipArchive;
$res = $zip->open($new_zip_file, ZipArchive::OVERWRITE);
if ($res !== true) {
die("Cannot open {$new_zip_file} for writing!");
}
else{
$res = $zip->extractTo($serverpath . '/customerdata/tmp_invoices/');
$zip->close();
}
} else
die("Upload failed with error code " . $_FILES['bulk_filename']['error']);
}
The problem that I see is that even if the function extractToreturns as successful extraction (1), I don’t see the files that were apparently extracted ?!
I always see the file Archive.zip, so I know that it loads correctly ...
-rwxr-xr-x 1 nginx nginx 68512374 May 4 12:39 Archive.zip
Any ideas on what I am doing wrong?!: - /
ENVIRONMENT: Centos 6 works with PHP 5.3.3
UPDATE
Below (with a full path) it does not produce any errors, it just does not work out any extraction ?!
$zip->extractTo($serverpath . '/customerdata/tmp_invoices/');
( ) Warning: ZipArchive::extractTo(): Permission denied in...?!
$zip->extractTo('/customerdata/tmp_invoices/');