Jump to content

$_FILES['userfile']['tmp_name']


doubledee

Recommended Posts

The 'userfile' key in the array is determined by what you named your file field in the HTML form.  In the following case:

 

<input type="file" name="thumbnail">

 

.. it would be $_FILES['thumbnail']['tmp_name']

 

It works this way since you might have multiple file fields in your form and would need to be able to differentiate between them.

Link to comment
Share on other sites

The 'userfile' key in the array is determined by what you named your file field in the HTML form.  In the following case:

 

<input type="file" name="thumbnail">

 

.. it would be $_FILES['thumbnail']['tmp_name']

 

It works this way since you might have multiple file fields in your form and would need to be able to differentiate between them.

 

The PHP Manual really sucks on this topic...  >:(

 

So, ['tmp_name'] is an "attribute" describing some aspec of ['thumbnail'], right?

 

Is so, then what is the "universe" of attributes describing the file in $_FILES??

 

Thanks,

 

 

Debbie

 

 

Link to comment
Share on other sites

So, ['tmp_name'] is an "attribute" describing some aspec of ['thumbnail'], right?

 

Is so, then what is the "universe" of attributes describing the file in $_FILES??

 

The, 'tmp_name' is the absolute path to the temporary file that your server processes the uploaded file as.  You can move the uploaded file to wherever you want it to be using this path once you are happy that it passes your requirements (e.g. file type, size etc.)

 

You could look at the W3 schools site for a decent-enough breakdown of the $_FILES array:

http://www.w3schools.com/php/php_file_upload.asp

 

If I recall correctly, a lot of the info in the array is provided by the user's browser during upload though so you can't really trust it (e.g. reported file type or size).  For this reason, you'll want to use PHP functions to actually access the file and determine it's attributes as part of your validation.

 

Finally, the $_FILES['thumbnail']['error'] value could be one of several values detailed here:

http://www.php.net/manual/en/features.file-upload.errors.php

Link to comment
Share on other sites

You seem to ask a lot of general questions that you can simply test yourself. If you are serious about programming, put in the time to test things yourself that you do not understand, which is essential for understanding concepts. Don't just post questions on here that you want a simple answer to from us when you can answer the question yourself. It's a waste of our time and yours. Btw, the php manual does a fine job of describing the $_FILES super global array.

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.