The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 23, 2019, 06:08:41 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Multipart Curl post  (Read 3026 times)
krustee
Rookie
**
Offline Offline

Posts: 33


View Profile
« on: November 06, 2009, 06:06:51 AM »

Well this is just wrecking my head completely been stuck at it for like 2 days.

I am trying to upload an image via multipart cURL post.

Here is the way I am setting my post array
Code:
$post_vars = array();
$post_vars['__LASTFOCUS'] = "";
$post_vars['__VIEWSTATE'] = $viewstate;
$post_vars['__EVENTTARGET'] = "";
$post_vars['__EVENTARGUMENT']="";
$post_vars['uisearch'] = "Search Share";
$post_vars['M$c$uiuploadmedia$uialbumcontribute$uialbumlist'] = $username . ".mymedia";
$post_vars['M$c$uiuploadmedia$uifile01'] = '@C:\wamp\www\oviproject-2\mickey.gif';

Here is the live http headers from when a file is uploaded manually. This is just a sampling. I am sure I am putting the file part of the area in wrong.

Code:
-----------------------------65002556626222
Content-Disposition: form-data; name="M$c$uiuploadmedia$uialbumcontribute$uialbumlist"

username.mymedia
-----------------------------65002556626222
Content-Disposition: form-data; name="M$c$uiuploadmedia$uifile01"; filename="mickey.gif"
Content-Type: image/jpeg


Do I not need to include "Content-Type: image/jpeg " in the file array and what way do I format this data.

Thanks for any help. I was trying to follow some of vsloathes threads on this but I just cant seem to find the answer to my question.
Logged
vsloathe
vim ftw!
Global Moderator
Lifer
*****
Offline Offline

Posts: 1669



View Profile
« Reply #1 on: November 06, 2009, 07:12:08 AM »

Don't single-quote encaps your file location. It's not a literal, you need the @ to be interpreted.
Logged

hai
krustee
Rookie
**
Offline Offline

Posts: 33


View Profile
« Reply #2 on: November 06, 2009, 07:55:06 AM »

Just got this working before you posted, havre to say this was frustrating as hell but its done now and I'm a little wiser. Thanks for the input VS
Logged
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #3 on: November 06, 2009, 06:11:33 PM »

Just got this working before you posted, havre to say this was frustrating as hell but its done now and I'm a little wiser. Thanks for the input VS

Glad you got it working.  What's the solution for the file upload portion?

Bompa
Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
krustee
Rookie
**
Offline Offline

Posts: 33


View Profile
« Reply #4 on: January 05, 2010, 05:13:31 AM »

Hey bomps sorry for the late reply.

Here is the function I wrote for uploading the file. Its not the cleanest code but it got the job done.

Code:
function upload_photo($username, $pid){

scrape_page("http://site.com", "",$pid);
$success = scrape_page("http://site.com/uploadmedia","http://site.com/",$pid);
preg_match("/action\=\"uploadmedia.uplx\?uploadid=(.*?)\" id\=\"aspnetForm/",$success,$matches);
$uploadid = $matches[1];
preg_match("/__VIEWSTATE\" value=\"(.*?)\" \/\>/",$success,$matches2);
$viewstate = $matches2[1];


$post_url = "http://site.com/uploadmedia.uplx?uploadid=" . $uploadid;
$post_vars = array();
$post_vars['__LASTFOCUS'] = "";
$post_vars['__VIEWSTATE'] = $viewstate;
$post_vars['__EVENTTARGET'] = "";
$post_vars['__EVENTARGUMENT']="";
$post_vars['uisearch'] = "Search site";
$post_vars['M$c$uiuploadmedia$uialbumcontribute$uialbumlist'] = $username . ".mymedia";
$post_vars['M$c$uiuploadmedia$uifile01'] = '@'."path to pic";

scrape_page("http://site.com/js/html/uploadprogress.aspx?albumname=".$username.".mymedia&uploadid=".$uploadid."&uploadcount=1", "http://share.ovi.com/uploadmedia",$pid);
$success = post($post_url, $post_vars, "http://share.ovi.com/uploadmedia",$pid);

$string = "picname";
$pos = strpos($success, $string);
return $pos;
}
Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!