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: <?php $site_name = $_SERVER['HTTP_HOST']; $url_dir = "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 > 500000) { $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 <a href=$file_url>$file_url</a>" : "Somthing is wrong with uploading a file."; debug_print_backtrace(); print_r($_FILES); return $message; } ?> <form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post"> Upload Image<input type="file" id="userfile" name="userfile"> <input type="hidden" name="MAX_FILE_SIZE" value="20000" /> <input type="submit" name="upload" value="Upload"> </form> 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