Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Curl an image from a container field

Featured Replies

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);

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.