Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automatically copy file field contents to text field

    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

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    <input type="file" onblur="this.form['texfieldname'].value=this.value">
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

    Appreciated.

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Kor
    <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.
    Code:
    <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">
    </form>
    any ideas?
    Last edited by tomsey11; 08-29-2006 at 09:28 PM.

  • #6
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    I believe it's a security violation to change the value of a file form field.

  • #7
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    suppose that makes sense thanks.

  • #8
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Quote Originally Posted by arnyinc
    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.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #9
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Helping to build a bigger box. - Adam Matthews


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •