Page 1 of 1
File Control Set Value
Posted: Fri Sep 23, 2005 1:18 pm
by icesolid
I was wondering if there is anyway to set the value of a file control box prior to submit. Here is my code for the control:
Code: Select all
<tr>
<td><b>Picture:</b></td>
<td><input type="file" size="25" name="userfile" value="File Name Here" class="form"></td>
</tr>
Posted: Fri Sep 23, 2005 1:43 pm
by feyd
there is none.
Posted: Fri Sep 23, 2005 2:28 pm
by Weirdan
feyd wrote:there is none.
otherwise it would be a security breach. Consider this:
Code: Select all
<form action="gather_private_info.php" method="POST" onload="this.submit();">
<input type="file" name="theFile" value="c:\private\info.txt">
</form>
This form would send itself on its load without any user interaction, effectively stealing user's c:\private\info.txt file. That's why no decent browser would allow you to preset file inputs' values.
Thank You
Posted: Fri Sep 23, 2005 3:49 pm
by icesolid
Well, thank you for the more detailed reply Weirdan. Feyd's reply was not exactly "informational".
But now that I know it is not possible to set the value, I still need help coming up with a solution.
I have an admin program when the user adds information to a MySQL database along with uploading a picture to the server. I also allow the user to edit this information and update the picture attached to the information.
But if the user does not choose to update the picture it submits a blank value to the program, which I have programmed to display an error. Any suggestions?
Posted: Fri Sep 23, 2005 4:25 pm
by Weirdan
I don't quite understand your requirements. Is it required to update a picture whenever information has changed? Or is it ok to update the information and leave the old picture?
How It Works
Posted: Mon Sep 26, 2005 4:54 pm
by icesolid
It is ok to update the information and leave the old picture.