| |
|
|
|
cURL Mailing List Monthly Index Single Mail
curl-and-php mailing list Archives
curl Upload: command line OK - libcurl/PHP problem!
From: Harry Fearnley <Harry.Fearnley_at_eng.ox.ac.uk>
Date: Fri, 02 Apr 2004 12:26:43 +0100
Dear fellow list member
curl Upload: command line OK - libcurl/PHP problem!
I _can_ upload a file using the curl command line interface (curl CLI)
It seems that to do an Upload I have to set the CURLOPT_UPLOAD option,
Please see the commented PHP code below.
Any ideas? ... must me something silly that I am(/not) doing ...
Thanks in advance.
Harry
+-+-+-+-+.+-+-+-+-+.+-+-+-+-+.+-+-+-+-+.+-+-+-+-+.+-+-+-+-+.+-+-+-+-+.+-+-+-+-+-
<?php
# Do the actual Upload!
### We are trying to mimic the effect of a curl command line that
### curl -v --insecure -b c2.txt -c c3.txt -o out.html -F
# First attempt to use libcurl from PHP to do a Weblearn Upload
# In a previous script we have done a logon to the server, supplied a
chdir("PDF/ENG2003");
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "./cookieFileName");
curl_setopt($ch, CURLOPT_URL, "https://site.ox.ac.uk/upload.html");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); # Equivalent to -k or
curl_setopt($ch, CURLOPT_VERBOSE, 1 );
$result = curl_setopt($ch, CURLOPT_POST, 1);
#$result = curl_setopt($ch, CURLOPT_PUT, 1); # Doing a PUT -- needs
#$result = curl_setopt($ch, CURLOPT_GET, 1);
$filename = "test.PDF";
$result = curl_setopt($ch, CURLOPT_INFILE, $handle );
$result = curl_setopt($ch, CURLOPT_INFILESIZE, filesize( $filename ) );
#$result = curl_setopt($ch, CURLOPT_UPLOAD, 1); # Prepare for an upload
# NOT setting this means that no attempt is made to upload the file --
# After setting CURLOPT_UPLOAD to 1, ...
curl_setopt($ch, CURLOPT_VERBOSE, 1); # to report everything
#curl_setopt($ch, CURLOPT_USERAGENT, "curl/7.10.6
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/6.0");
# We must supply a browser name (? and version) -- if we do not, then
$result = curl_setopt($ch, CURLOPT_POSTFIELDS,
# We authenticated via log on using the previous scripts, so now
$buffer = curl_exec ($ch); // execute the curl command
curl_close ($ch);
echo "<PRE>" . htmlentities($buffer) . "<BR>\n";
These mail archives are generated by hypermail. |
Page updated November 12, 2010.
web site info