File Input Field -> Remember the filepath on reload??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

File Input Field -> Remember the filepath on reload??

Post by seodevhead »

Hey guys... just like when you have regular text field form elements that have the ability to "remember" what you put in them on reload (just in case you forgot to fill something out and didn't want to lose all your other input data) like below:

Code: Select all

<input type="text" name="lastName" value="<?php
if (isset($_POST['lastName'])) echo $_POST['lastName']; ?>" />
..How do you do the same with a file input field for attaching files? (ie. <input type="file" name="upload" /> )

Everything I have tried doesn't seem to be reloading that file attachment path from the user's computer in those file field elements on a page reload... so the user has to "re-attach" those files one by one again. Any idea how this can be done? Thanks a bunch.
printf
Forum Contributor
Posts: 173
Joined: Wed Jan 12, 2005 5:24 pm

Post by printf »

You can't load a file input, it's a security feature built into the browser! You could just allow the upload and store it in a temp place. Then move it when the other parts of the form are corrected. Then setup a cron to dump all the temp files that were not moved because the user didn't finish filling in the form. This is best way if your dealing with bigger files, so the user doesn't have to upload the file again...

me!
Post Reply