1

I have the Uploadify jQuery plugin set up on my site to manage file uploads. Within the onUploadSuccess event, I have this code:

'onUploadSuccess' : function(file, data, response) {
    console.log("Upload complete for file " + file.name + ". Script returned: " + data);
}

This is meant to show me whatever the upload script spits out. Now, usually the response is something like this:

Upload complete for file test.jpg. Script returned: {"status":1,"file":{"id":"v8rwlxj3","name":"test.jpg"}}

The upload script is first accepting the file, then uploading it to Rapidshare using cURL like so:

// Move uploaded file
move_uploaded_file($_FILES['Filedata']['tmp_name'], $targetDir . '/' . $id);

// Get the RapidShare server to upload to
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=nextuploadserver');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(!$uploadServer = trim(curl_exec($ch))) {
    error('nextuploadserver failed');
}
if(strstr($uploadServer, 'ERROR:')) {
    error('nextuploadserver failed');
}

// Upload the file to RapidShare
$uploadID = mt_rand(1000000000, 9999999999);
$url = 'http://rs' . $uploadServer . '.rapidshare.com/cgi-bin/rsapi.cgi?uploadid=' . $uploadID;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
$postFields = array('sub' => 'upload',
                    'login' => 'login',
                    'password' => 'password',
                    'uploadid' => $uploadID,
                    'filename' => $_FILES['Filedata']['name'],
                    'filecontent' => '@' . $targetDir . '/' . $id);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
if(!$resp = curl_exec($ch)) {
    error('upload call failed');
}

when it's uploaded, the upload script spits out a JSON response like so:

// Output
echo json_encode(array('status' => 1, 'file' => array('id' => $id, 'name' => $uploadDetails[1])));

This works fine for smaller files. When I upload my 30MB test file however, I get this response:

Upload complete for file 30mb.txt. Script returned:

At first I thought PHP was hitting the max execution time, but I have this at the top of my script:

set_time_limit(21600); // 6 hours

And besides, I'd see the PHP error being returned. But it's just not returning anything. What could cause this? Thanks.

James Dawson
  • 5,309
  • 20
  • 72
  • 126
  • PHP may be not hitting time limit, but ajax may be reaching connection timeout while waiting for the response – dev-null-dweller Jun 16 '12 at 20:47
  • Ah, that may be it. Uploadify assumes the upload was successful if it doesn't receive a response back from the script after 30 seconds. I'll set the success timeout to something high then see if it works. Thanks. – James Dawson Jun 16 '12 at 22:21

4 Answers4

0

Are you sure your upload_max_filesize is set to above 30M? That one has caused me some headaches in the past.

Henrik Karlsson
  • 5,559
  • 4
  • 25
  • 42
  • Yeah, the large files still get uploaded to Rapidshare and they're stored in my local directory so I know for a fact that the uploads are working. It just seems that the script is returning prematurely (the upload to Rapidshare is still running after the script has "returned"). – James Dawson Jun 16 '12 at 20:02
0

PHP may be not hitting time limit, but ajax may be reaching connection timeout while waiting for the response.

dev-null-dweller
  • 29,274
  • 3
  • 65
  • 85
0

Remove uploadid post parameter. Uploadid parameter with resume upload.

0

Yes nice answer, although it was in comment but helped me. http://www.uploadify.com/documentation/uploadify/successtimeout/

set successTimeout to some high value. lets say 1 hour.

hridayesh
  • 1,123
  • 1
  • 14
  • 36