CLI-Curl zu PHP-Curl zum Hochladen der DateiPhp

PHP-Programmierer chatten hier
Anonymous
 CLI-Curl zu PHP-Curl zum Hochladen der Datei

Post by Anonymous »

Ich versuche, den Aufruf der PHP-Curl-Bibliothek so einzurichten, dass er Folgendes annimmt:

Code: Select all

curl --location \
--header "authorization: LOW $accesskey:$secret" \
--upload-file /home/samuel/public_html/intro-to-k.pdf \
http://s3.us.archive.org/sam-s3-test-08/demo-intro-to-k.pdf
(Dies ist für die API des Internetarchivs: http://archive.org/help/abouts3.txt)

Dies ist derzeit auf einer Windows 7-Entwicklungsbox, wird aber auf Ubuntu umgestellt

Ich habe versucht:

Code: Select all

        $ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('authorization: LOW XXXX:XXXXX'));
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_URL, 'http://s3.us.archive.org/a_tested_working_dir/the_file_ane_and_ext' );
$post_array = array(
"upload-file"=>file_get_contents($absolute_path_to_my_file)
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array);
$response = curl_exec($ch);
echo $response;
Fehler: MalformedPOSTRequest. Der Text Ihrer POST-Anfrage ist nicht wohlgeformt. Ich schaffe es einfach nicht, den PHP-Curl richtig hinzubekommen

TIA!



Ein --libcurl-Dump wurde erzeugt:

Code: Select all

CURLcode ret;
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_INFILESIZE_LARGE, (curl_off_t)64d);
curl_easy_setopt(hnd, CURLOPT_URL, "http://s3.us.archive.org/jeffs_test_1301_librivox/test-francesbaird3.mp3");
curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(hnd, CURLOPT_UPLOAD, 1);
curl_easy_setopt(hnd, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.21.1 (i686-pc-mingw32) libcurl/7.21.1 OpenSSL/0.9.8r zlib/1.2.3");
curl_easy_setopt(hnd, CURLOPT_CAINFO, "C:\Program Files\Git\bin\curl-ca-bundle.crt");
curl_easy_setopt(hnd, CURLOPT_SSL_VERIFYPEER, 1);
curl_easy_setopt(hnd, CURLOPT_SSH_KNOWNHOSTS, "c:/Users/JMadsen/_ssh/known_hosts");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50);
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
Ich denke, es könnte eine SSL-Überprüfung sein, aber ich habe gerade versucht, es auf „false“ zu setzen und keine Änderung

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post