1

I'm submitting video from my iOS app to my server, and receiving a PHP error code 3 - 'The uploaded file was only partially uploaded.'. However, this is only occurring some times and I haven't found a pattern with it yet. I'm using ASIFormDataRequest to send the files.

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:urlUpload];
request.shouldContinueWhenAppEntersBackground = YES;
[request setFile:@"filename"
         withExtension:@".mov"]
         withFileName:@"filename.mov"
         andContentType:@"video/quicktime"
         forKey:@"Filedata"];
request setDelegate:self;
[request setUploadProgressDelegate:self;
[request setShowAccurateProgress:YES];
[request startAsynchronous];

With urlUpload being defined earlier in the process.

My php script looks like:

if (isset($_FILES['Filedata'])) {
    if ($_FILES['Filedata']['error']) {
        echo "File Error";
    } else {
        //Handle the upload file
    }
} else {
    echo "No File";
}

The error associated with $_FILES['Filedata']['error'] is 3, which PHP states is a partially uploaded file, and $_FILES['Filedata']['size'] is 0.

Any thoughts as to what might be going on? Or better yet, a solution that ensures we get the complete file?

adamame
  • 188
  • 11

1 Answers1

1

I'm not sure but what I do know is that when the script finishes the uploaded file is gone, so you have to copy it to somewhere else on your server.

if (file_exists("upload/" . $_FILES["file"]["name"]))
  {
  echo $_FILES["file"]["name"] . " already exists. ";
  }
else
  {
  copy($_FILES["file"]["tmp_name"],
  "upload/" . $_FILES["file"]["name"]);
  echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
  }

some prefer to use move_uploaded_file() but some are getting copy errors with that function. copy generally works.

too bad this is such a late reply, hope it can still be of service

  • 1
    I discovered the real problem was losing part of the file over the internet connections. I wrote a way to upload the file in small chunks, and if a chunk gets lost, resubmit that chunk. With each chunk, I appended it to a file I created on our server. – adamame May 04 '12 at 17:39