PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Wed Mar 29, 2006 3:36 am
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
shankimout
Forum Newbie
Posts: 3 Joined: Wed Mar 29, 2006 6:21 am
Location: Iran ( Mazandaran )
Contact:
Post
by shankimout » Wed Mar 29, 2006 6:41 am
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
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Wed Mar 29, 2006 6:49 am
Im trying to get this done using cURL.