Retaining file name in <input type=file...
Hi, I have a form with a bunch of text boxes and a file browser. I have a Python function which scans the file selected and fills in the text boxes with the result when you press the appropriate action button. Then with the text boxes filled in for you, you just press the submit button. Problem: the selected file name has disappeared. I acheive filling in the text boxes in the Python function by using... REQUEST.set("description", what_i_want_to_go_in_it). Each text box in the DTML form looks something like this... <textarea name="description" cols="55" rows="4" wrap="virtual"> <dtml-var expr="REQEST.get('description','')" html_quote></textarea> This works OK, the problem is I would like the file name to stay put when I come back to it. It keeps comming back with a blank box right now. This is the present DTML... <input type="file" name="file" size="40" value="<dtml-var expr="REQUEST.get('file',')" html_quote>" ...and in the Python function... REQUEST.set('file', REQUEST.file) ...and I have also tried... REQUEST.set('file.filename', REQUEST.file.filename) ...neither of which works. Any suggestions on how to preserve the file name would be most welcome. Regards, Simon B.
This is the present DTML... <input type="file" name="file" size="40" value="<dtml-var expr="REQUEST.get('file',')" html_quote>"
...and in the Python function... REQUEST.set('file', REQUEST.file) ...and I have also tried... REQUEST.set('file.filename', REQUEST.file.filename) ...neither of which works.
Any suggestions on how to preserve the file name would be most welcome.
Urm, I think you're screwed since I'm pretty sure browsers ignore any value set in a file tag :-( Maybe some JavaScript could hack it? cheers, Chris
Simon Blandford writes:
This is the present DTML... <input type="file" name="file" size="40" value="<dtml-var expr="REQUEST.get('file',')" html_quote>" Probably for security reasons, the browser ignores the initial value of "file" controls. Otherwise, it would be quite easy to steal files from un-cautious users....
Dieter
participants (3)
-
Chris Withers -
Dieter Maurer -
Simon Blandford