• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2069
  • Last Modified:

CURl Multi-Part Form Data

I am working with an API, and I am posting to it using CURL, but I need to now extend it to simulate post data should be formatted as multipart/form-data as such:
- media (required) - Binary image data
- username (required) - Twitter username
- password (required) - Twitter password
- message (optional) - Message to post to twitter. The URL of the image is automatically added.

The media that I am trying to post is on a diffferent website, so how can I open this image, and then do a post of it using CURL?

I can't seem to figure it out.

Thanks!
0
interclubs
Asked:
interclubs
  • 3
  • 2
1 Solution
 
interclubsAuthor Commented:
I'm updating this questions, I found the answer here:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_22448898.html

But, is there a way to make it work with files that aren't in the local file system?
0
 
Ray PaseurCommented:
Where would the non-local files be found? ~Ray
0
 
interclubsAuthor Commented:
0
 
Ray PaseurCommented:
You can use file_get_contents to access the non-local files.  Then you can save them on your server.  After that you should be able to put the requisite data into the CURL command.  Read up on file uploading here:http://us.php.net/manual/en/features.file-upload.php

HTH, ~Ray
0
 
Ray PaseurCommented:
Thanks for the points.  Best of luck with it, ~Ray
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now