Re: [PHP] Re-populating File field in form - won't work??
I think it's a "security" feature to prevent people from doing things like inserting a hidden file field with a pre-defined value (e.g.: "/etc/passwd") and then tricking the user to unwittingly submit the form. The same probably applies to all browsers. On Mon, 2002-10-14 at 16:05, Monty wrote: > I have a few File input fields in a form so people can upload images. If > there's an error with the form, I want to re-populate the fields with the > values the user filled in. This works for all the fields except the File > fields. When I check the HTML output to the browser, I do see that the value > parameter (value="filename.jpg") is set for the File field, however, when > viewing the form the field appears blank. Also, if you leave it blank and > click Submit, I get an error stating it was empty, so, clearly the File > field is blank and not showing the default value that has been set. > > Is this my browser (IE 5.5 on Mac) or does a File field not accept default > values?? > > Thanks! > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re-populating File field in form - won't work??
> I have a few File input fields in a form so people can upload images. If > there's an error with the form, I want to re-populate the fields with the > values the user filled in. This works for all the fields except the File > fields. When I check the HTML output to the browser, I do see that the > value > parameter (value="filename.jpg") is set for the File field, however, when > viewing the form the field appears blank. Also, if you leave it blank and > click Submit, I get an error stating it was empty, so, clearly the File > field is blank and not showing the default value that has been set. > > Is this my browser (IE 5.5 on Mac) or does a File field not accept default > values?? I'm pretty sure this doesn't work for security reasons. Otherwise, you could modify the value of the element with javascript when the form is submitted and actually upload any file from the users computer. For anything to be sent with a File field, the user has to click Browse and select the file. Maybe you could save the uploaded files somewhere in a temp folder and make the File fields hidden elements instead of actual file elements. The value of the hidden element would be the file you stored in temp. Be sure you validate this. It'd be better yet to store the file names in the session, let the user correct the other parts of the form, and then process everything. Hope that's not too confusing... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re-populating File field in form - won't work??
I have a few File input fields in a form so people can upload images. If there's an error with the form, I want to re-populate the fields with the values the user filled in. This works for all the fields except the File fields. When I check the HTML output to the browser, I do see that the value parameter (value="filename.jpg") is set for the File field, however, when viewing the form the field appears blank. Also, if you leave it blank and click Submit, I get an error stating it was empty, so, clearly the File field is blank and not showing the default value that has been set. Is this my browser (IE 5.5 on Mac) or does a File field not accept default values?? Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php