I have a HTML page,where file input type is defined. but when i try uploading it, its not working using move function. then found that, echoing file name itself not printing anything after selecting any file...
HTML:
<form id="upload_items" name="upload_items" method="post" action="items.php">
<input type="file" name="itemlist_file" id="itemlist_file" />
<br /> <br />
<input type="submit" name="Upload" value="Upload" id="Upload" />
</form>
Form submission php page:
error_reporting(E_ERROR | E_PARSE);
echo (basename($_FILES["itemlist_file"]["name"])
Output:
Nothing displayed...
You need to add this to the form :-
enctype='multipart/form-data'
enctype='multipart/form-data
is an encoding type that allows files to be sent through a POST. Quite simply, without this encoding the files cannot be sent through POST.
You forgot to provide the correct enctype which is obligatory for uploads. Add the enctype attribute to your form like:
<form id="upload_items" name="upload_items method="post" action="items.php" enctype="multipart/form-data"> ...