I'm not sure if that is possible. I think you have to click the browse button and select the file. I don't think you can set values with javascript to "file" inputs. That'd be a security hole if that would be possible.
I don't think you can set values with javascript to "file" inputs.
I don't want to do this.
I have the following file fields:
Code:
<input type="file" name="userFile[]" size="20"> <!-- Need to send data to parent page hidden field 1 -->
<input type=file name=userFile[] size=20> <!-- Need to send data to parent page hidden field 2 -->
I need to extract the selected file names and send the file names to corespondent hidden field on parent page.
With only one value work:
Code:
self.opener.document.foo.attach1.value = document.filesform.UserFile1.value;
and
<input type="file" name="userFile1" size="20" >
why are you naming all the inputs the same? you could just give them all a different name, this makes it a little easier. that way you can place them in an array and then loop over them, just as you do with the attach fields.
Ok I a modify each input field for different name.
But exist a way to manage this different names with php ?
just store all the names of the input fields in an array, or if they have a logical name, you might wonna browse over them using a for loop.
either this:
PHP Code:
$fields = array('field_name1', 'field_name2', 'etc...');
for($i=0; $i<sizeof($fields); $i++){
//do something with the input
}
or this:
PHP Code:
for($i=0; $i<$number_of_fields; $i++){
$input = $_FILES['field'.$i];
//do something with the input
}
Hope this helps you,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks