I have a php script that uploads images to a folder.
It is working locally, but when I put it on the hosting server I get the following error message:
[Thu May 18 21:45:00.833970 2017] [fcgid:warn] [pid 37560] [client 151.229.83.93:44238] mod_fcgid: stderr: PHP Notice: Undefined index: file in /home/linnas01/g/domainname.com/user/htdocs/php/uploadphoto.php on line 9, referer: http://domainname.com/photoupload.html
Can anyone explain why this is happening and how to fix this?
The php looks like this
<?php
if ( 0 < $_FILES['file']['error'] ) {
     echo 'Error: ' . $_FILES['file']['error'] . '<br>';
 }
 else {
     move_uploaded_file($_FILES['file']['tmp_name'], 'images/' . $_FILES['file']['name']);
 }
?>
My html file looks like this
<form enctype="multipart/form-data">
    <input id="upload-input" type="file" name="file" multiple="multiple" enctype="multipart/form-data">
    <input type="submit">
</form>
The file gets posted with ajax.
 var formData = new FormData();
 for (var i = 0; i < files.length; i++) {
     var file = files[i];
     fileNames.push(file.name);
    // add the files to formData object for the data payload
    formData.append("image", file);
  }
$.ajax({
    url: 'uploadphoto.php',
    type: 'POST',
    data: formData,
    processData: false,
    contentType: false,
    success: function(data){
       console.log(data);
    }
});
I have also configured the directories and files as explained here.
 
     
    