bobthedog Posted July 27, 2010 Posted July 27, 2010 Hiya, I am trying to upload an image using Smartpill and cURL to my webservice. The following code works well to grab an image from a URL and then upload it to my webservice. My problem however is how to get the image from a container field instead of a URL. I think it is only grabbing the name of the image, not the actual file itself? I am using Windows. Can anyone help? $url = 'http://sprott.physics.wisc.edu/fractals/carlson/PGPHX82.GIF'; $datain = file_get_contents($url); $ctype= "image/gif"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://garytest.nordic-e.com/__API__/picture/8/data"); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_USERPWD,"testuser:testpass"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type" => $ctype)); curl_setopt($ch, CURLOPT_POSTFIELDS, $datain); $data = curl_exec($ch); print curl_error($ch); echo $data; curl_close($ch);
Recommended Posts
This topic is 5485 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now