SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict Divisive Cotton's Avatar
    Join Date
    Jun 2008
    Location
    Andy lives in London, UK
    Posts
    393
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A quick question on file uploads

    When I write a form in php I would write something like this:

    Code:
    <label for="title">Title:</label>
    <input type="text" name="title" id="title" value="<?php
    
    isset($_POST['title']) ? print $_POST['title'] : null;
    
    ?>" />
    This means that the user entered value is still present after clicking on submit

    Is there something I can use for file upload which remembers the users found path after browse in the event of form submit? Otherwise the user has to click browse and find the file after every form submit and which is annoying if errors are present
    Let everyday be Christmas

  2. #2
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately not, the user has to select the file again.

  3. #3
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    My advice would be to copy the upload temp file to your own temp directory and store it until either a certain amount of time expires (say 30 minutes?) and then send a cookie that tracks it's location, listing the filename instead of having an upload box. When they send the rest of the form without errors, just use the existing file instead of forcing them to waste bandwidth uploading it again.

    Either that, or put all the things they could make errors on in the first page, and then have a second page (upload auth cookie hash?) that has just the upload dialog... or reverse that. I've seen several websites where you upload the file, THEN you fill out all the extra information.

  4. #4
    SitePoint Guru
    Join Date
    Jan 2007
    Posts
    936
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    A common technique is to put the file uploader in its own independent form with an iframe. The value can be passed to the main form with Javascript. As DeathShadow indicated, a folder can be used for temporary storage and moved with submission of the main form.


Bookmarks

Posting Permissions

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