I have a form and when the user submits the form I want to save information in inputs, for cases where error happen, users dont need to write the information again.
So Im using this method in code below and it works fine, but only for my input type="file" dont works, when I submit the form, the file that the user choose is not saving.
Is necessary some trick in this case of <input type="file">
?
<form action="" method="post" enctype="multipart/form-data">
<label class="line">
<span class="data">Select an Image:</span>
<input type="file" class="fileinput" name="thumb" size="60" value="<?php if(isset($_POST['thumb'])) echo $f['thumb'] ?>" />
</label>
<label class="line">
<span class="data">Title:</span>
<input type="text" name="title" value="<?php if(isset($_POST['title'])) echo $f['title']; ?>" />
</label>
<label class="line">
<span class="data">Content:</span>
<textarea name="content" rows="15"><?php if(isset($_POST['content'])) echo htmlspecialchars($f['content']); ?></textarea>
</label>
<label class="line">
<span class="data">Date:</span>
<input type="text" name="date" value="<?php if(isset($_POST['date'])) echo $f['date']; else echo date('d/m/Y H:i:s'); ?>" />
</label>
<input type="submit" value="Insert" name="sendForm"/>
</form>
My code where I Do the upload:
if(!empty($_FILES['thumb']['tmp_name']))
{
$folder = '../uploads/';
$year = date('Y');
$month = date('m');
$img = $_FILES['thumb'];
$ext = substr($img['name'],-3);
uploadImage($img['tmp_name'], $f['url'].'.'.$ext, $folder.$year.'/'.$month.'/');
}