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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.