Jump to content

Can't get file upload to work - is_uploaded_file($_FILES... returns false


noldguy

Recommended Posts

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        750

file_uploads          on
upload_max_filesize    16M
post_max_size          8M
upload_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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.