Jump to content

[SOLVED] Persistence of input type="file" fields


darkblue

Recommended Posts

Dear all,

 

I have a spot of bother with a PHP file upload form. Basically I have a file upload field and some other assorted fields. Each of these fields run some server side validation. The problem arises when one of the other fields does not pass validation. How can I get the data input in the file field to remain in the field?

 

I've tried:

<form <snip>...</snip>>
    <snip>...</snip>
    <input type="file" name="filename" value="<?=$_POST['filename'];?>" />
    <input type="text" name="otherfield" value="<?=$_POST['otherfield'];?>" />
</form

 

...and...

 

<form <snip>...</snip>>
    <snip>...</snip>
    <input type="file" name="filename" value="<?=$_FILES['filename'];?>" />
    <input type="text" name="otherfield" value="<?=$_POST['otherfield'];?>" />
</form

 

... but neither have the desired effect. Does anyone know what I need to do to get the previous file selected to persist in the file field on reload, or if this is even possible?

 

Cheers.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.