0

Hi,
I want to upload files from one remote server to another using CURL

I used following to upload a text file in "localhost/uploads/example.txt" to another machine http://192.168.0.202/example/

<?php


$ch = curl_init();

$data = array('name' => 'Foo', 'file' => '@localhost/uploads/example.txt');

curl_setopt($ch, CURLOPT_URL, 'http://192.168.0.202/example/');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_exec($ch);
?>

The code is not working.

4
Contributors
5
Replies
8
Views
5 Years
Discussion Span
Last Post by ainosilva
0

i don't think you have permissions to do that on remote.. :S but you can try file_get_contents (i guess it will do the same, but...)

<?php
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>

Edited by ainosilva

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.