Assign VALUE to INPUT type FILE

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Assign VALUE to INPUT type FILE

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.. :?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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']:""); ?>">
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Post Reply