I just referred [this doc](http://php.net/manual/en/features.file-upload.post-method.php) for error handling .

**code**

```
 /*foreach ($_FILES["file"]["error"] as $key => $error) {
    print_r($error);
    if ($error == UPLOAD_ERR_OK) {
        move_uploaded_file($_FILES['file']['tmp_name'], $path);
    }
  }*/

  if(is_uploaded_file($_FILES['file']['tmp_name']) && move_uploaded_file($_FILES['file']['tmp_name'], $path)) 
  {
    die('{"success":"The file ".  basename( $_FILES["file"]["name"]).  has been uploaded"}');
  }else
  {
    die('{"error" :  "There was an error uploading the file, please try again!"}');
  }

```

If i use the commented part instead uncommented, my file is not uploading. But i referred the documentation to handle size, extension errors. Please let me know if i understood anything wrongly.

And nothing gets printed if i try `print_r($_FILES)` in the console.
How do i make my forst method working.