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

11-05-2010, 01: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);

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

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

$zip->close(); }

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

11-05-2010, 01: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

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


11-05-2010, 02: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