var_dump() returning zero arry. unable to upload file PHP

148 Views Asked by At

upload.php

The var_dump() function is returning zero array. What am i doing wrong here ?

<form method="post" action="upload.php">

    <input type="file" name ="file" id="file"><input type="submit" value="upload">

</form>
<?php 


if(isset($_POST['file']))
{   


   var_dump($_FILES);


}   
?>
2

There are 2 best solutions below

0
Shankar Narayana Damodaran On

You need to add the form enctype

<form method="post" action="upload.php" enctype="multipart/form-data">
0
웃웃웃웃웃 On

You need to add enctype="multipart/form-data" to your form to upload files

<form method="post" action="upload.php" enctype="multipart/form-data">

Check this for more