#30858 [Fbk->Opn]: Upload permission error
ID: 30858 User updated by: michaelchikit at gmail dot com Reported By: michaelchikit at gmail dot com -Status: Feedback +Status: Open Bug Type: Filesystem function related Operating System: Fedora 3 PHP Version: 5.0.2 New Comment: I have upgraded to Apache 2 too and new os to Fedora 3 Please try the following code: http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']); $url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; $upload_dir = '/var/www/html/upload/'; $upload_url = $url_dir."upload/"; $message =""; error_reporting(E_ALL); ini_set('display_errors', TRUE); if (is_readable($_FILES['userfile']['tmp_name'])) { echo "I can read " . $_FILES['userfile']['tmp_name']; } if ($fp0 = fopen('upload_files/doodah', 'w')) { echo 'I can open upload/doodah for writing'; } if ($fp1 = fopen('upload_files/' . $_FILES['userfile']['name'], 'w')) { echo 'I can open upload_files/' . $_FILES['userfile']['name'] . ' for writing'; } if (is_dir('upload_files')) { echo ('upload_files is valid a directory'); } else { echo ('upload_files is NOT a directory'); } if (is_writeable('upload_files')) { echo ('I am able to write to upload_files'); } else { echo ('I am NOT able to write to upload_files'); } if ($_FILES['userfile']) { $message = do_upload($upload_dir, $upload_url); } else { $message = "Invalid File Specified."; } print $message; function do_upload($upload_dir, $upload_url) { $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; } //File Size Check else if ( $file_size > 50) { $message = "The file size is over 500K."; return $message; } //File Type Check else if ( $file_type == "text/plain" ) { $message = "Sorry, You cannot upload any script file" ; return $message; } //$result = move_uploaded_file($temp_name, $file_path); $result = copy($temp_name, $file_path); $message = ($result)?"File url $file_url" : "Somthing is wrong with uploading a file."; debug_print_backtrace(); print_r($_FILES); return $message; } ?> Upload Image Previous Comments: [2004-11-29 08:25:21] [EMAIL PROTECTED] But in addition to upgrade of PHP you upgraded the whole server. Please, add more information on how we can reproduce your problem. [2004-11-29 00:27:31] 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-27 09:28:49] [EMAIL PROTECTED] Why do you think it's a bug in PHP and how can we reproduce it? [2004-11-26 01:11:42] michaelchikit at gmail dot com I tried to use abd path. This is not working [2004-11-25 23:10:27] [EMAIL PROTECTED] Try it using absolute path for destination file. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/30858 -- Edit this bug report at http://bugs.php.net/?id=30858&edit=1
#30858 [Fbk->Opn]: Upload permission error
ID: 30858 User updated by: michaelchikit at gmail dot com Reported By: michaelchikit at gmail dot com -Status: Feedback +Status: Open Bug Type: Filesystem function related Operating System: Fedora 3 PHP Version: 5.0.2 New Comment: 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. Previous Comments: [2004-11-27 09:28:49] [EMAIL PROTECTED] Why do you think it's a bug in PHP and how can we reproduce it? [2004-11-26 01:11:42] michaelchikit at gmail dot com I tried to use abd path. This is not working [2004-11-25 23:10:27] [EMAIL PROTECTED] Try it using absolute path for destination file. [2004-11-22 06:02:13] 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. -- Edit this bug report at http://bugs.php.net/?id=30858&edit=1
#30858 [Fbk->Opn]: Upload permission error
ID: 30858 User updated by: michaelchikit at gmail dot com Reported By: michaelchikit at gmail dot com -Status: Feedback +Status: Open Bug Type: Filesystem function related Operating System: Fedora 3 PHP Version: 5.0.2 New Comment: I tried to use abd path. This is not working Previous Comments: [2004-11-25 23:10:27] [EMAIL PROTECTED] Try it using absolute path for destination file. [2004-11-22 06:02:13] 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. -- Edit this bug report at http://bugs.php.net/?id=30858&edit=1