2017-05-18 20:48
浏览 68


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] mod_fcgid: stderr: PHP Notice: Undefined index: file in /home/linnas01/g/ on line 9, referer:

Can anyone explain why this is happening and how to fix this?

The php looks like this


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">

The file gets posted with ajax.

 var formData = new FormData();

 for (var i = 0; i < files.length; i++) {
     var file = files[i];

    // add the files to formData object for the data payload
    formData.append("image", file);

    url: 'uploadphoto.php',
    type: 'POST',
    data: formData,
    processData: false,
    contentType: false,
    success: function(data){

I have also configured the directories and files as explained here.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题