php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30858 Upload permission error
Submitted: 2004-11-22 06:02 UTC Modified: 2005-01-04 06:16 UTC
Votes:5
Avg. Score:4.6 ± 0.8
Reproduced:5 of 5 (100.0%)
Same Version:5 (100.0%)
Same OS:4 (80.0%)
From: michaelchikit at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.0.2 OS: Fedora 3
Private report: No CVE-ID: None
 [2004-11-22 06:02 UTC] michaelchikit at gmail dot com
Description:
------------
I have tried this code in my old server that is working very fine. But after I upgraded my server into Fedora 3 and PHP 5.0.2. that generated the followings error. The server does not allow me to upload the file and say permission denied. But I am very very sure, I have set the correct permission with the dir. The mode of upload_files and its parenet dir are 0777.

Is it a bug of PHP?


Reproduce code:
---------------
	$temp_name = $_FILES['userfile']['tmp_name'];
	$file_name = $_FILES['userfile']['name']; 
	$file_type = $_FILES['userfile']['type']; 
	$file_size = $_FILES['userfile']['size']; 
	$result    = $_FILES['userfile']['error'];
	$file_url  = $upload_url.$file_name;
	$file_path = $upload_dir.$file_name;

	//File Name Check
    if ( $file_name =="") { 
    	$message = "Invalid File Name Specified";
    	return $message;
    }


    $result  =  move_uploaded_file($temp_name, $file_path);


Expected result:
----------------
No Error , the file should be appeared in the dir

Actual result:
--------------
Warning: move_uploaded_file(upload_files/Sunset.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /var/www/html/simple_upload.php on line 47

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpO1zvJO' to 'upload_files/Sunset.jpg' in /var/www/html/simple_upload.php on line 47
Somthing is wrong with uploading a file.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-25 23:10 UTC] tony2001@php.net
Try it using absolute path for destination file.
 [2004-11-26 01:11 UTC] michaelchikit at gmail dot com
I tried to use abd path.
This is not working
 [2004-11-27 09:28 UTC] tony2001@php.net
Why do you think it's a bug in PHP and how can we reproduce it?
 [2004-11-29 00:27 UTC] michaelchikit at gmail dot com
Because I have tried this script into a older version PHP server, this is working.
But my new PHP5 + Apache 2 server can't make this script working.
 [2004-11-29 08:25 UTC] tony2001@php.net
But in addition to upgrade of PHP you upgraded the whole server.
Please, add more information on how we can reproduce your problem.
 [2005-01-04 06:16 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

There is no bug here. Ask support questions on how to install/ configure PHP on the proper mailing list.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC