1

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);


}   
?>
Shankar Narayana Damodaran
  • 66,874
  • 43
  • 94
  • 124
Eskinder
  • 1,299
  • 1
  • 12
  • 24

2 Answers2

6

You need to add the form enctype

<form method="post" action="upload.php" enctype="multipart/form-data">
Shankar Narayana Damodaran
  • 66,874
  • 43
  • 94
  • 124
3

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

Community
  • 1
  • 1
Deepu
  • 11,587
  • 13
  • 55
  • 88