A quick question on file uploads

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


<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

Unfortunately not, the user has to select the file again.

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.

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.