LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   move_uploaded_file failed to open stream: Permission denied (https://www.linuxquestions.org/questions/linux-server-73/move_uploaded_file-failed-to-open-stream-permission-denied-721133/)

zawmn83 04-23-2009 06:52 AM

move_uploaded_file failed to open stream: Permission denied
 
Hi

I'm developing a website with PHP 5 and Apache.
There is a php page to upload files to webserver and some FTP users need to access to these uploaded files.
So I create a new group named G1 and add this group to both apache and FTP users.
Then set the permission of upload destination folder to 774, set owner to FTP user account and set group to G1.

When I try to upload file from php page, the following warning occur

Warning: move_uploaded_file(../papers/myfile.doc) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/httpd/vhosts/mydomain/httpdocs/mysite/upload-form.php on line 93

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpuXqVpb' to '../papers/myfile.doc' in /home/httpd/vhosts/mydomain/httpdocs/mysite/upload-form.php on line 93


When I click Refresh button on this warning page, the following message appear with Resend and Cancel button.
"To display this page, Firefox must send information that will repeat any action (such as a search or order confirmation) that was performed earlier.".
I click Resend, the same warning page with different tmp file occur.

The strange thing is after I click Refresh button 4 or 5 time, the file is successfully uploaded and no warning appear.
Then I try again for another file, the same warning appear again. And I need to click Refresh 4 or 5 to upload success.

Please help me to find out what is the source of issue.

Thanks

rylan76 04-29-2009 09:08 AM

Are you using SELinux on that system?

I'm asking, because that sounds like the typical type of illogical tomfoolery an enforcing SELinux installation can cause.

The first thing I always do is turn off SELinux on any new install I do... it causes unneccessary complexities and is IMO much too complicated for general use outside of the needs of the National Security Agency.

If you ARE using SELinux, try turning it off, and see if the problem persists.

Also:

Quote:

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpuXqVpb' to '../papers/myfile.doc' in /home/httpd/vhosts/mydomain/httpdocs/mysite/upload-form.php on line 93
musn't

Quote:

'../papers/myfile.doc' in
be

Quote:

/home/httpd/vhosts/mydomain/httpdocs/mysite/papers/myfile.doc
for it to work? I. e. your destination path is incorrectly specified in the call to move_uploaded_file?

zawmn83 05-01-2009 10:00 PM

Thanks for your reply.

I haven't no permission to turn off SELinux on server.
The destination path is correct. Because after I click Refresh button a few times, it is successfully uploaded to destination path.



Quote:

Originally Posted by rylan76 (Post 3524721)
Are you using SELinux on that system?

I'm asking, because that sounds like the typical type of illogical tomfoolery an enforcing SELinux installation can cause.

The first thing I always do is turn off SELinux on any new install I do... it causes unneccessary complexities and is IMO much too complicated for general use outside of the needs of the National Security Agency.

If you ARE using SELinux, try turning it off, and see if the problem persists.

Also:



musn't



be



for it to work? I. e. your destination path is incorrectly specified in the call to move_uploaded_file?


rylan76 05-04-2009 03:36 AM

Quote:

Originally Posted by zawmn83 (Post 3527395)
Thanks for your reply.

I haven't no permission to turn off SELinux on server.
The destination path is correct. Because after I click Refresh button a few times, it is successfully uploaded to destination path.

The strange thing here is the fact that you say "a few times" - i. e. it seems as if something has to "catch up" to your actions. This is why I suggested SELinux - i. e. maybe some dynamic permission allocation function / process has to complete before you can upload the file - the only thing I can think of that might do something like this is SELinux.

Have you checked whether you need to ALWAYS click the SAME number of times before it starts working, or is it always a variable number of seconds before it starts working??


All times are GMT -5. The time now is 04:37 PM.