I can't figure out how to pass a c:\... filepath via curl for an RFC1867
multipart form upload in PHP 5.2.1.
I'm using the following code to perform a programmatic file upload to
the PHP server:
$filepath='/home/user/testfile.txt';
$ch=curl_init('http://bucksvsbytes.com/upload.php');
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,array('peru'=>'@'.$filepath));
curl_exec($ch);
curl_close($ch);
Works great if the file I want to upload is on the web server but it
never is. The files I want are on the client computer, of course, e.g.
c:\home\user\testfile.txt
I've tried passing every variation of that path I can think of, e.g.:
C:\home\user\testfile.txt
C:\\home\\user\\testfile.txt
C:/home/user/testfile.txt
urlencode(...)
utf8_encode(...)
and nothing works. I either get the dreaded "failed creating formpost
data" or the filepath shows up in $_POST and $_FILES is empty. The
listed formats don't work with fopen() either.
I've searched dozens of web examples but I can't get it. Help!
For that matter, is there a better approach than curl for programmed
uploads of client computer files to the PHP server?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php