dpacmittal Posted July 20, 2009 Share Posted July 20, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/ Share on other sites More sharing options...
rhodesa Posted July 20, 2009 Share Posted July 20, 2009 Does it seem to fail after a specific time interval? Specifically, try adding this to the beginning of the script: set_time_limit(0); Quote Link to comment https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/#findComment-878905 Share on other sites More sharing options...
dpacmittal Posted July 20, 2009 Author Share Posted July 20, 2009 Does it seem to fail after a specific time interval? Specifically, try adding this to the beginning of the script: set_time_limit(0); I've already added that along with: ini_set(”memory_limit”,”200M”); Quote Link to comment https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/#findComment-878910 Share on other sites More sharing options...
rhodesa Posted July 20, 2009 Share Posted July 20, 2009 have you set this too? ini_set ("display_errors", "1"); error_reporting(E_ALL); there aren't any errors showing up on the screen or in the php error log? Quote Link to comment https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/#findComment-878912 Share on other sites More sharing options...
mattal999 Posted July 20, 2009 Share Posted July 20, 2009 Maybe the server that you were sending the file to timed out, and refused connection. Not sure though. Try echoing any cURL errors during execution. Quote Link to comment https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/#findComment-878920 Share on other sites More sharing options...
dpacmittal Posted July 20, 2009 Author Share Posted July 20, 2009 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()? Quote Link to comment https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/#findComment-878927 Share on other sites More sharing options...
rhodesa Posted July 20, 2009 Share Posted July 20, 2009 why would the cookie file help? Try using cURL to download the file too...instead of file_get_contents() Quote Link to comment https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/#findComment-878931 Share on other sites More sharing options...
dpacmittal Posted July 20, 2009 Author Share Posted July 20, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/#findComment-878936 Share on other sites More sharing options...
rhodesa Posted July 20, 2009 Share Posted July 20, 2009 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)); Quote Link to comment https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/#findComment-878940 Share on other sites More sharing options...
dpacmittal Posted July 20, 2009 Author Share Posted July 20, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/#findComment-878962 Share on other sites More sharing options...
rhodesa Posted July 20, 2009 Share Posted July 20, 2009 what does your download code look like? Quote Link to comment https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/#findComment-878967 Share on other sites More sharing options...
dpacmittal Posted July 20, 2009 Author Share Posted July 20, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/166681-solved-file-uploads-breaking-in-curl/#findComment-878975 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.