A
Anonymous
Guest
Hi, I have uploaded a file in my database below row named 'file_name'. Now when I open my edit form in view mode, the file name does not show (is empty) and when I save the form, the file_name goes blank from the database. I want to save the file in edit form so each time I save the form, the already uploaded file should show in database. I know that value cannot be used for files for security reasons and I also know how to just echo the name of file, but I need to keep the already uploaded file in edit form.
This is my code in edit form in view mode:
This is my code in model:
Any advice would be very helpful. Many thanks.
This is my code in edit form in view mode:
Code:
<div class="form-group">
<label for="example-text"><?php echo get_phrase('Browse File');?></label>
<input type="file" name="file_name" id = "file_name" class="form-control-file"/><span name="old" id = "old"><?php echo $row['file_name'];?></span>
</div>
This is my code in model:
Code:
$page_data['file_name'] = $_FILES["file_name"]["name"];
$oldfile = $_POST['old'];
$file = $_FILES["file_name"]["name"];
if($file != "") {
move_uploaded_file($_FILES["file_name"]["tmp_name"], "uploads/parents_image/" . $_FILES["file_name"]["name"]);
} else {
$file = $oldfile;
$page_data['file_name'] = $this->input->post('file_name');
}
Any advice would be very helpful. Many thanks.