How can I get the html form name from php with multiple file uploads?
If I do something like this to get handle file uploads:
if ($_FILES) {
foreach ($_FILES as $file) {
//...Handle the upload process
}
}
Is there any way that I can get the key of the file? As in:
<input type="file" name="myfile" />
I want to know that the file is coming from "myfile".
E开发者_JS百科dit: The obvious solution to this turns out to be:
foreach($_FILES as $key => $file) {
$input_name = $key;
// Handle upload.
}
If the input name in your form is myfile
, then it will be in the $_FILES
array as:
$_FILES['myfile']
So you can do:
foreach ($_FILES as $inputName => $fileInfo) {
}
Check out Handling file uploads for more info.
精彩评论