0

I want to save image to this 'http://198.164.241.108/~bss/api/images/upload_images';location

I tried the following

$url = 'http://198.164.241.108/~bss/api/images/upload_images';

$img = $_FILES['image']['tmp_name'];

file_put_contents($img, file_get_contents($url));

Using Curl

$ch = curl_init();

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, array('file' => $_FILES["image"]["tmp_name"]));

curl_setopt($ch, CURLOPT_URL, '`http://198.164.241.108/~bss/api/images/upload_images`');

curl_exec($ch);
curl_close($ch);

But both of these not working

H Aßdøµ
  • 2,925
  • 4
  • 26
  • 37
Akshaya Moorthy
  • 309
  • 3
  • 11
  • Of course it will not work - you need to emulate the form submission. The best way to achieve it - with help of cURL functions. Analyze the data sent from the form and http://stackoverflow.com/questions/3085990/post-a-file-string-using-curl-in-php – Cheery Oct 07 '14 at 06:17

1 Answers1

0

As i understand, it's remote server, so you have to make connection to that server and use ftp_put(). Also, to use $_FILES global variable, you need to use some HTML form first (i hope you just skipped this obvious part in your question).

Justinas
  • 41,402
  • 5
  • 66
  • 96