I've a form with too many fields. One of these fields is as follows:
<form action="go_to_preview.php" role="form" method="post" enctype="multipart/form-data"> <input type="file" name="equip_image" id="equip_image"> </form>
Now the purpose of file
go_to_preview.php is to show the data filled in by user in the form of labels. All the filled in data are also contained in hidden fields. There is also one Submit button present on this form. If user finds whatever he/she has filled in is perfect then user clicks the submit button present on file
go_to_preview.php. As soon as user clicks on submit button I'll add the data I received through
$_POST to the database.
Now my issue is I'm not able to upload the file selected by user from the page containing file control. Along with
$_POST(which is an array of data present into hidden fields) I'm sending the
$_FILES array in a Session as follows :
//go_to_preview.php session_start(); $_SESSION['FILES'] = $_FILES; //final.php session_start(); $files_var = $_SESSION['FILES']; //use $files_var unset($_SESSION['FILES']);
Till now everything goes fine. Now when I submit the form I've to upload the selected file to the server. For it I wrote following logic in final.php file :
move_uploaded_file( $_SESSION['FILES']['equip_image'], $target); unset($_SESSION['FILES']);
The function gets executed properly but the file is not getting uploaded to the server. Can someone please help me in this regard? Thanks in advance. If you don't get my doubt clear you can also refer to my following question to get the clear idea of my issue: How to get the $_FILES array data as it is after form submission in following scenario?