...

View Full Version : Resolved fopen()failed to open stream: Permission denied >> after moving to Linux



fail
11-05-2010, 02:02 PM
I have this fopen() script that ran fine on Windows, but now on Linux it give me a "Permission denied" error.

The data.zip file does not exist and should be created with fopen()

Any ideas?




$fp = fopen('data.zip', 'w'); // << error is on this line
fwrite($fp, $inhalt);
fclose($fp);

$zip = new ZipArchive;
$res = $zip->open('data.zip');
if ($res === TRUE) {

$path = getcwd() . "/test/";
$path = str_replace("\\","/",$path);
mkdir($path, 0777);

$zip->extractTo($path);
$zip->close(); }

abduraooft
11-05-2010, 02:05 PM
Any ideas? Check the permission settings of that directory and make sure that the write permission is there.

poyzn
11-05-2010, 02:12 PM
Also check ownership of this folder. Must be available to write for www-data
to set ownership for folder run

chown -hR root:www-data /folder_name
and set writeable by groups

fail
11-05-2010, 02:34 PM
I got it done by changing the directories to 0777

Thanks!

MattF
11-05-2010, 03:55 PM
Unless the httpd daemon is running as a different user to both the owner:group for the directories, you'd be better going to 0770 maximum. You've given full access to any user with the 0777.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum