Sunday 15 February 2015

php - sending uploaded file to another server via CURL from a CURLed page -


How many examples have I seen how to upload a file with the CRL (probably closest to what I need), but

What I'm trying to achieve : Curl a file upload form from the server, display it on surfer1. Select a file to upload via this form, submit the form, but submit it to SERVER1, press $ _POSTS and $ _FILES and then submit it to the form processing script on SERVER2 and display the results in SERVER1 .

In other words, I have an action file upload and processing interface on SERVER2, but I need to make it as everything is happening on the server.

This is like me SERVER1:

  // on the related code so loop foreach ($ k = $$ k => by submitting files. $ V) {$ settings] $ $ [$ k] = '@' ['Tmp_name']; } $ Settings = http_build_query ($ settings); $ Cookie = WP_CONTENT_DIR '/ Plugins / myPlugin / cookie.txt'; // SERVER1 is a WordPress site $ ch = curl_init ($ url); Curl_setopt ($ ch, CURLOPT_POST, true); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, true); Curl_setopt ($ CH, CURLOPT_POSTFIELDS, $ settings); Curl_setopt ($ CH, CURLOPT_SSL_VERIFYPEER, FALSE); Curl_setopt ($ ch, CURLOPT_USERAGENT, "Mozilla / 5.0 (Windows; U; Windows NT 5.1; N-US; RV .: 1.8.1.6) Gecko / 20070725 Firefox / 2.0.0.6"); Curl_setopt ($ ch, CURLOPT_TIMEOUT, 60); Curl_setopt ($ CH, CURLOPT_FOLLOWLOCATION, 0); Curl_setopt ($ ch, CURLOPT_COOKIEJAR, $ cookie); Curl_setopt ($ ch, CURLOPT_COOKIEFILE, $ cookie); Curl_setopt ($ ch, CURLOPT_REFERER, $ url); $ Response = curl_exec ($ ch);   

When I return the output $ response (which includes print_r ($ _ files), the files come in the form of an empty array and the following error occurs: Warning: file_get_contents (@ / Tmp / phpFITW6K): Failed to open stream: no such file or directory

What am I missing? I noticed that http_build_query is missing from some curl instances and passed instead of an array, but does not give me a "request request data with POST request, or the amount of data provided in the request is greater than the capacity limit. " If I

Any help would be appreciated. I was not completely sure that "http_build_query () was removed from http_build_query () and keeping '@' in front of the file name" Request request does not allow data with POST requests or provided in the request The quantity of data is greater than the capacity limit "error, but the file is now properly received and parsed on the server.

No comments:

Post a Comment