noldguy Posted November 29, 2006 Share Posted November 29, 2006 Problem: is_uploaded_file($_FILES['userfile']['tmp_name']) returns false. All $_FILES['userfile'] fields contain "A" (garbage I suppose).I have been unable to get file upload to work. Posted my code to another forum. One member responded saying he saw no problem with the code. Then exchanged 20+ emails with web host tech support. They created the "uplod" directory and set upload_tmp_dir to it's current value. Didn't solve the problem. My test file is a 2.5k gif.I am perplexed, frustrated and at wits end. Anyone have any ideas?[b]Server info (shared host):[/b][code]Server info (shared host):Apache nobody(99)/99/home/mbiwebor/uplod 99/99 755/home/mbiwebor/public_html 32050/99 750file_uploads onupload_max_filesize 16Mpost_max_size 8Mupload_tmp_dir /home/mbiwebor/uplod (note: originally was "no value")open_basedir /home/mbiwebor/:/usr/lib/php:/usr/local/lib/php:/tmp[/code][b]Form code[/b] (.htaccess is set so server will parse .html as php)[code]<form enctype='multipart/form-data' action='nomedit.html' method='post'> <input type='hidden' name='select' value='{$_REQUEST['select']}' /> <input type='hidden' name='nominee_id' value='{$_REQUEST['nominee_id']}' /> <input type='hidden' name='MAX_FILE_SIZE' value='30000' /> <span class='stress small'>Upload photo file</span> <input class='small' name='userfile' type='file' /> <input class='small' name='upload' type='submit' value='Upload' /></form>[/code][b]Processing code[/b][code]function processUpload() { global $err_msg; if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { $destination = $_SERVER['DOCUMENT_ROOT'] . '/2007/photos' . basename($_FILES['userfile']['name']); if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $destination)) { $err_msg = 'File move to photos directory was not successfull'; return; } } else { $err_msg = "File was not uploaded successfully - error code: {$_FILES['userfile']['error']}<br />"; return; }}[/code]Note that there is more to the processing code that I will add after the upload is working. Link to comment https://forums.phpfreaks.com/topic/28851-cant-get-file-upload-to-work-is_uploaded_file_files-returns-false/ Share on other sites More sharing options...
benji87 Posted November 29, 2006 Share Posted November 29, 2006 All i notice is that your form action is a html file and not php. Your processing code wont work if its not in php. Link to comment https://forums.phpfreaks.com/topic/28851-cant-get-file-upload-to-work-is_uploaded_file_files-returns-false/#findComment-132068 Share on other sites More sharing options...
noldguy Posted November 29, 2006 Author Share Posted November 29, 2006 It works thanks to AddType application/x-httpd-php .html :) Link to comment https://forums.phpfreaks.com/topic/28851-cant-get-file-upload-to-work-is_uploaded_file_files-returns-false/#findComment-132299 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.