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.

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

 

 

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

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.

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.