Page 1 of 1
Uploading file to http via cURL
Posted: Wed Mar 29, 2006 3:36 am
by anjanesh
Code: Select all
$url = "domain.com/post.php"
$Data = "";
$Data .= "otherPOSTvars=POSTvalues&";
$Data .= "file=@temp.txt&";
$h = curl_init();
curl_setopt ($h, CURLOPT_POST, TRUE);
curl_setopt ($h, CURLOPT_POSTFIELDS, $Data);
curl_setopt ($h, CURLOPT_URL, $url);
curl_setopt ($h, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt ($h, CURLOPT_FOLLOWLOCATION, TRUE);
$c = curl_exec($h);
For some reason the file temp.txt never gets uploaded.
Any idea why ?
Thanks
Posted: Wed Mar 29, 2006 6:41 am
by shankimout
you can open a socket and send a http request then send the files with http
this an simple http request
Code: Select all
POST /upload.php HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*
Accept-Language: en-us
Content-Type: multipart/form-data; boundary=---------------------------7d61f4180376
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
Host: localhost:801
Content-Length: 353
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: lastactivity=0
-----------------------------7d61f4180376
Content-Disposition: form-data; name="fileaa"; filename="C:\Documents and Settings\Ebrahim\My Documents\ghfh.txt"
Content-Type: text/plain
$filedata
-----------------------------7d61f4180376--
7d61f4180376 is a random string
Posted: Wed Mar 29, 2006 6:49 am
by anjanesh
Im trying to get this done using cURL.