View Full Version : Automatically copy file field contents to text field

08-29-2006, 04:46 PM
I have a PHP upload form, but i want the contents of the file field (containing the path to file being uploaded) to be automatically copied to another normal text field whenever the contents are changed.

How can i do this?

Thanks alot :)

08-29-2006, 05:04 PM
<input type="file" onblur="this.form['texfieldname'].value=this.value">

08-29-2006, 08:57 PM
Thanks alot!

This may be pushing my luck, but is there also a way to do the oposite? Automatically change the value in a file field by whats in a text field?


08-29-2006, 09:52 PM
Yes. as a mirror

<input type="text" onblur="this.form['inputfilename'].value=this.value">

Aren't you intend to "customize" an input type="file"? Take care about the length. FF will not accept CSS modifying of the typo "file" input's length.

08-29-2006, 10:18 PM
<input type="text" onblur="this.form['inputfilename'].value=this.value">

That isn't working for me. This is how i implemented it, and it hasn't worked.

<form name="form1" enctype="multipart/form-data" method="post" action="processFiles.php">
<input name="uploadFile1" type="file" id="uploadFile1" size="20">
<input type="submit" name="Submit" value="S">
<input type="text" onblur="this.form['uploadFile1'].value=this.value">
:( any ideas?

08-29-2006, 10:33 PM
I believe it's a security violation to change the value of a file form field.

08-29-2006, 10:35 PM
suppose that makes sense :( thanks.

08-29-2006, 10:44 PM
I believe it's a security violation to change the value of a file form field.
Well yes... I was thinking of a javascript trick:

Aren't you intend to "customize" an input type="file"?

case in which in fact you write on the file form, but you see the result in text form.

08-30-2006, 02:50 AM
Here's a trick: