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
  • 68,075
  • 43
  • 96
  • 126
Eskinder
  • 1,369
  • 1
  • 14
  • 24

2 Answers2

6

You need to add the form enctype

<form method="post" action="upload.php" enctype="multipart/form-data">
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
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
웃웃웃웃웃
  • 11,829
  • 15
  • 59
  • 91