Page 1 of 1

Assign VALUE to INPUT type FILE

Posted: Wed Aug 11, 2004 11:10 pm
by anjanesh
Is it not possible to assign a VALUE to input type FILE ?

Code: Select all

<INPUT TYPE="file" NAME="File1" VALUE="<? echo (isset($_POST['File1'])?$_POST['File1']:""); ?>">
Im doing this when an error occurs and the user doesn't have to type the non error data once again.

Posted: Wed Aug 11, 2004 11:13 pm
by feyd
uh... it wouldn't be stored in $_POST['File1'] ... it'd be available through $_FILES['File1']['name'], however, the file would have already been uploaded to your server.. :?

Posted: Wed Aug 11, 2004 11:19 pm
by anjanesh
I already tried that feyd. But $_FILES wasn't working too.
And no nothing was posted (uploaded) until the error value is 0

This is actual scenario - its multiple upload

Code: Select all

for ($i=0;$i<10;$i++)
 echo <INPUT TYPE="file" NAME="File1[]" VALUE="<? echo (isset($_FILES['File1'])?$_FILES['File1'][$i]['name']:""); ?>">

Posted: Wed Aug 11, 2004 11:30 pm
by feyd
hmm well, doing a quick check in the Javascript standards, File form elements, have a value, that is read-only. It cannot be set by a script, nor present in the html.

Posted: Wed Aug 11, 2004 11:34 pm
by anjanesh
Oh.Ok Thanks
From where are you referring the Javascript standards ? W3.org ?
I normally check netscape since they are the ones who defined it.
W3C just mentions that VALUE is optional. It doesn't say anything specific to FILE

Posted: Wed Aug 11, 2004 11:45 pm
by feyd