Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

input type="file" value="x"

  • 29-03-2006 07:32PM
    #1
    Closed Accounts Posts: 975 ✭✭✭


    I'm playing with file uploads in php. I have a form with various fields including 5 input type="file" fileds. I have a routine to check for duplicates, as well as other parsing logic.

    Now if there is an error in the form on submission, I redisplay the form and populate it with the data that was submitted last time, but this won't work for the file fields.

    If I do:
    <input type="file" name="x" <?php echo "value=" . $x; ?> >

    The raw HTML generated looks like:

    <input type="file" name="x" value="C:\about.jpg">

    But the file field is empty on the form.

    This link says it's a security thing:
    http://www.irt.org/script/1154.htm

    Are they right?
    Is there a workaround?
    I don't want the user having to reselect 5 files if there is an error.
    Thanks.


Comments

  • Registered Users, Registered Users 2 Posts: 1,275 ✭✭✭bpmurray


    Actually, the security restriction is that you can't set the value programmatically or with a default value. However, if you have a signed script, you can work around this. I've done it before, but can't remember how - you should be able to google it.


  • Closed Accounts Posts: 850 ✭✭✭DOLEMAN


    I'm nearly certain there is no work around for this.

    Considering: I write a script. Force an error to occur so the user has to reenter his password again. I then change the file upload path to point at a very private file...


Advertisement