Link to home
Start Free TrialLog in
Avatar of TheMaximumWeasel
TheMaximumWeasel

asked on

POST a file and other values to a url then store the response - NO PEAR

I need to post a file along with some variables I have in an array to a url then get the response. How can I do this without pear?

Max
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

TheMaximumWeasel,

How about PHP cUrl (http://us3.php.net/curl).  It will do what you need.  Check PHPInfo to see if it is already an option on your server.  Let me know if you need details.

Let me know if you have any questions or need more information.

b0lsc0tt
Avatar of TheMaximumWeasel
TheMaximumWeasel

ASKER

I do have curl installed, I would like an example of posting a file along with values from an array. I have seen many curl posting examples, but have found none that explain posting files.

Max
When you say posting a file do you actually mean something like a multipart form?  A binary file, etc?

I haven't seen an example for that either.  Do you already have some code or which part do you need help on?  Can you post just the array values and need help sending the file too?  Let me know what you have and I'll be happy to provide more if I can.  I am not sure I would have time to make a complete example of this for you, definitely couldn't do it for at least 24 hours.

Thanks for letting me know about cUrl. :)

bol
Well, I am using an api class that uses pear to post an image along with some variables to a url, then it parses the xml response. I need to find a away to post the image with the variables in the same request without using curl. If you can find a guide someone online to do this, that would be sufficient.

Max
Without using curl or pear?  I believe you meant pear but please clarify.  You have piqued my curiosity on why you can't use pear for this when you do have it and use it.

Assuming I was right about the typo do you know how to use cUrl for everything but sending the image then?  I can look into that part and might have time to even do a test.

Let me know if I am off base or understanding you right.

bol
oh sorry, thats not what I meant to say. I meant without using pear, curl is fine. I don't know how to post an image with curl,  thats the problem. The reason I can't use pear is because my host (DreamHost) doesn't support it.

Max
ASKER CERTIFIED SOLUTION
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
k I will look at those and see if I run into any problems, if it works I will award you with the points.

Thanks,
Max
Cool!  Let me know if you have a question.  I don't normally like to just give links and will be happy to do what I can to get that "Excellent." :D

bol
what does @ do? like when they use @$file to make curl not see it as a string?

Max
That is a good question.  Usually it is placed in front of a function or a function call to suppress errors.  That doesn't really seem to apply here.  There was a note for one of the other "options" that the symbol was used to designate a file.  Although the comments I linked to didn't use that option it does seem to be used for the same purpose.  I haven't seen any documentation to confirm this though.

bol
I actually got pear working, thanks for helping me with curl though.
Your welcome!  I"m glad I could help. Thanks for the fun question, the grade and the points.

bol