Home > database >  APACHE Permissions are all set but still don't have permission (*Solved*)
APACHE Permissions are all set but still don't have permission (*Solved*)

Time:10-25

I recently faced this issue, as you can see in the picture, i granted all sorts of permissions to all files, but still i get this error.

Here's the code:

$zipdir=dirname(dirname(__FILE__)).'/tmp';
$zipname="$zipdir/$input[user]-".time().'.zip';
list($pdf,$pdfname)=test_pdf($request);
$zip=new ZipArchive();
if ($zip->open($zipname,ZipArchive::CREATE)!==true) return $error='Could not open zip archive for writing';
$zip->addFromString("pdf/$pdfname", $pdf->Output('','S'));
$zip->addFile("test-docs/",$testformname);
$zip->close();
if (!file_exists($zipname)) return $error='Could not create zip archive';

https://i.stack.imgur.com/kmxUg.png

And here's the log :

PHP Warning:  ZipArchive::close(): Failure to create temporary file: Permission denied in /var/www/html/test/app/test.php

What is wrong you think?

CodePudding user response:

Problem just solved!

I needed to grant 775 or above permission to the whole "html" folder in this path :

"/var/www/html/..."

Not just files and folders in it because i tried that completely.

Also apache:apache permission is not needed, root does the work.

This comment helped a lot:

move_uploaded_file gives "failed to open stream: Permission denied" error

  • Related