The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 16, 2019, 11:14:55 PM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: How can I do a multipart form http post without curl?  (Read 3220 times)
windtalker
n00b
*
Offline Offline

Posts: 8


View Profile
« on: October 06, 2009, 01:49:42 PM »

I need to do a multipart/form-data post and I can not use curl, so it must be straight php. How can this be accomplished? I appreciate any help with this.
Logged

No links in signatures please
DangerMouse
Expert
****
Offline Offline

Posts: 244



View Profile
« Reply #1 on: October 06, 2009, 03:35:06 PM »

You can do this by talking directly the socket and sending appropriate HTTP headers, then handling the subsequent responses.

Clearly this is quite tricky so I'd suggest you take a look at existing web request libs - PEAR has a comprehensive one, and there is a great one on this forum that Perk has been good enough to contribute (not sure if this handles multipart, but it can certainly be adapted to do so).

There are others here who are far more competent than me to explain the technical elements required to manage sockets directly so I shall leave that to them! Smiley

DM
« Last Edit: October 06, 2009, 04:06:43 PM by DangerMouse » Logged
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #2 on: October 06, 2009, 03:38:02 PM »

There are remnants from my first shot at multipart in the current class ... I don't think I ever finished it though. But it is a fine basis from which to work forward WindTalker, if you want to build your own.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #3 on: October 06, 2009, 05:52:43 PM »

I need to do a multipart/form-data post and I can not use curl, so it must be straight php. How can this be accomplished? I appreciate any help with this.

Switch to a real language like Perl.

Wink


But seriously, when I need to do something that a Perl module (class) does, yet I can not use
that particular module, I study how the module does it.


Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #4 on: October 06, 2009, 05:54:07 PM »

Switch to a real language like Perl.

Don't make me...

(Actually WOW! Cool sarcasm and language bias from Bomps! Right on man!)
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
deregular
Expert
****
Offline Offline

Posts: 172


View Profile
« Reply #5 on: October 07, 2009, 03:32:33 AM »

Couldnt you just set sessions across the pages, and then when its submitted, delete the session?
Logged
windtalker
n00b
*
Offline Offline

Posts: 8


View Profile
« Reply #6 on: October 07, 2009, 12:26:10 PM »

Thanks guys, I'll also give a look at perks' class..

Couldnt you just set sessions across the pages, and then when its submitted, delete the session?
deregular I don't understand, how can sessions help send a multipart/form-data POST?
Logged

No links in signatures please
deregular
Expert
****
Offline Offline

Posts: 172


View Profile
« Reply #7 on: October 11, 2009, 09:48:33 PM »

Perhaps im missing something, but understand multipart to mean across seperate pages...

So from the first page, there would be a next button, which would throw everything from the form into the session,
and then the next page and then the next page, until you get to the end and then the session vars would be sent
through for processing.

ahhhhhhhh........

Now i get it, you mean on someone elses site. Sorry I just misunderstood your initial post.
Logged
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #8 on: October 12, 2009, 02:27:08 AM »

Perhaps im missing something, but understand multipart to mean across seperate pages...

So from the first page, there would be a next button, which would throw everything from the form into the session,
and then the next page and then the next page, until you get to the end and then the session vars would be sent
through for processing.

You get it now, but since you asked, it reminds me that I thought the same thing
a while back.  There are probably others wondering also.

There are two different methods to submit forms

In Perl, they would look something like this:
1. Content-Type => 'application/x-www-form-urlencoded
2. Content_Type => 'form-data'

The difference that I know of are that the form-data (multi part) can include
a file such as a image.

Probably 90% of forms use the first.

Bompa



Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
nop_90
Global Moderator
Lifer
*****
Offline Offline

Posts: 2203


View Profile
« Reply #9 on: October 12, 2009, 06:11:26 PM »

Get perks HTTP class.

Read the offical spec how multipart works
http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2
Basically the fields are seperated by a "boundry"

Should not be too difficult to add in the option for multipart for post data for perks class.
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!