Repopulate file fields?

Discussion in 'PHP' started by jsamdirect, Oct 8, 2007.

  1. #1
    I am trying to create a form for uploading files. Currently when the form is submitted the data is checked via php to assure the data is valid. If it is not, the form is redisplayed with the message advising the user to fix the errors. When the form is redisplayed it is populated with the data originally entered.

    This method works will with non $_FILE fields but with file fields I cannot figure out how to repopulate the field. Which means if there is an error with one file field, all will blank out when the form is redisplayed.

    Anyone know how I can get the submitted data, i.e.; /home/pics/mypic.gif, from the form so I can redisplay it if needed?
     
    jsamdirect, Oct 8, 2007 IP
  2. chicagoweb

    chicagoweb Peon

    Messages:
    30
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can always copy the file to another location, and reference it back using sessions for example.
     
    chicagoweb, Oct 8, 2007 IP
  3. tamen

    tamen Peon

    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can't. Or, rather, you shouldn't.

    Imagine a form with an invisible file input with the file /users/username/my_secret_passwords.txt already filled in. Guess what would happen when you submitted that form :)
     
    tamen, Oct 8, 2007 IP