Jump to content

Recommended Posts

Well, I am making this script which downloads a file from another server and uploads it to file hosting site.

 

The problem is that it breaks in between. The file size is 22mb and sometimes it uploads 15mb, sometimes 18, sometimes 9.

 

Is there anyways I can solve this or is this a server problem?

 

BTW, I am using curl to download and upload.

Link to comment
https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/
Share on other sites

I just did but it doesn't give any errors but still the files are incomplete.

 

The problem doesn't seem to be with uploading. I think its the downloading part.

 

Can we use the cookie file generated by CURL with fopen or file_get_contents()?

why would the cookie file help?

 

Try using cURL to download the file too...instead of file_get_contents()

I am using CURL for downloading the file. The user needs to login to download the file. Thats why I need the cookie file.

 

I am asking if I can use any alternate method for downloading in which I could use the cookie file for authentication.

ah, ok, well it should be pretty straight forward in determining if the problem is download or upload. I assume you know how big the file is supposed to be after downloading.

 

are we confident it's the download that is the problem? after the download completes, what is the output of:

print_r(curl_getinfo($ch));

ah, ok, well it should be pretty straight forward in determining if the problem is download or upload. I assume you know how big the file is supposed to be after downloading.

 

are we confident it's the download that is the problem? after the download completes, what is the output of:

print_r(curl_getinfo($ch));

 

Yes, I am pretty sure its the problem with downloading. I've checked the original file's size and downloaded file's size.

 

And the statement you gave didn't output anything. Is it because of error?

Thanks guys. It feels really stupid but when Rhodesa asked for code, I was copying - pasting it here, and i saw this:

 

curl_setopt($ch, CURLOPT_TIMEOUT, 50);

 

Please don't feel angry. Actually I just copied-pasted it from another script of mine which needed the timeout. I just didn't notice that I forgot to remove it.

 

Sorry for trouble, once again. It was a sheer stupidity at my part. Damn! I am embarrased.

 

Its working now.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.