开发者

When upload file: Curl return "Empty reply from server" only on Linux but Windows

开发者 https://www.devze.com 2023-03-06 20:13 出处:网络
when I upload a file to Mediafire Hosting by use CURL, i get \"Empty reply from se开发者_Python百科rver\" on Ubuntu, CentOs

when I upload a file to Mediafire Hosting by use CURL, i get "Empty reply from se开发者_Python百科rver" on Ubuntu, CentOs but with same code ,I can upload that file on Windows. What Linux difference from Windows ? How can i solve this matter ?


I have encountered this problem and finally found that it is caused by the office network firewall strategy;

I compiled various versions of Curl and OpenSSL, but it is always the window machine can be used normally, and the two devices in the Linux environment can not upload files, and the JSON and download files function normally; finally found that it is office The firewall policy of the network leads to the fact that my window computer has passed the network authentication and has high authority. However, the two devices of Linux have limited network permissions, cannot upload files, but can use JSON and download files.

Because it is a test environment, LINUX successfully uploads files through TCP port mapping on the window;


Try changing the user agent to see if that makes a difference. For example:

curl --user-agent "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24"


Use ReturnTransfer before CURL_FILE

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_FILE, $fp); 

http://www.php.net/manual/en/function.curl-setopt.php#99082

I don't know why i use RETURNTRANSFER after CURLOPT_FILE and it work in Windows O_O. even in Linux , i use same as Windows, i can upload to many hosting but Mediafire. very strange ><

0

精彩评论

暂无评论...
验证码 换一张
取 消