doubledee Posted February 13, 2012 Share Posted February 13, 2012 What is $_FILES['userfile']['tmp_name']?? Is it a two-dimensional array? Why can't I have a $_FILES['tmp_name']?? Debbie Quote Link to comment https://forums.phpfreaks.com/topic/257004-_filesuserfiletmp_name/ Share on other sites More sharing options...
Pikachu2000 Posted February 13, 2012 Share Posted February 13, 2012 $_FILES is a multidimensional, superglobal array. Quote Link to comment https://forums.phpfreaks.com/topic/257004-_filesuserfiletmp_name/#findComment-1317479 Share on other sites More sharing options...
codebyren Posted February 13, 2012 Share Posted February 13, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/257004-_filesuserfiletmp_name/#findComment-1317480 Share on other sites More sharing options...
doubledee Posted February 13, 2012 Author Share Posted February 13, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/257004-_filesuserfiletmp_name/#findComment-1317482 Share on other sites More sharing options...
trq Posted February 13, 2012 Share Posted February 13, 2012 You could find out for yourself by using: var_dump($_FILES['thumbnail']); Quote Link to comment https://forums.phpfreaks.com/topic/257004-_filesuserfiletmp_name/#findComment-1317515 Share on other sites More sharing options...
codebyren Posted February 13, 2012 Share Posted February 13, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/257004-_filesuserfiletmp_name/#findComment-1317518 Share on other sites More sharing options...
AyKay47 Posted February 13, 2012 Share Posted February 13, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/257004-_filesuserfiletmp_name/#findComment-1317585 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.