How to remember input value for type=file on post?
Posted: Fri Jan 23, 2009 3:23 pm
Hi,
I was wondering if anyone could help me on this one? I'm trying to make an image gallery admin area in PHP and I'm trying to add a system kind of like the phpMyAdmin interface i.e. when adding a table you can add more rows- and when you add a new row all the <input>'s values are remembered. I know how to do this using every form element except for type='file'! Just to clarify:
Any help would really be appreciated! I have a feeling it might not be possible because of something to do with security, but if it is it would save me looking into java!
Thanks in advance
I was wondering if anyone could help me on this one? I'm trying to make an image gallery admin area in PHP and I'm trying to add a system kind of like the phpMyAdmin interface i.e. when adding a table you can add more rows- and when you add a new row all the <input>'s values are remembered. I know how to do this using every form element except for type='file'! Just to clarify:
Code: Select all
<?php
$error = false;
if (isset($_POST['upload'])) {
if (!trim($_POST['title'])) {
$error = true;
}
if (!$error) {
# finish the job
}
}
?>
<html>
...
<form method="post" action="" enctype="multipart/form-data">
<input type="text" name="title" <?php if ($error) {echo 'value="'.htmlspecialchars($_POST['title']).'"';} ?> /><br />
<input type="file" name="image" <?php if ($error) {echo "HOW DO YOU GET THE USER INPUT BACK?";} ?> />
<input type="submit" name="upload" value="Upload" />
</form>
...
</html>Thanks in advance