0

I want to do the send image file name and path to external server after saved locally. My form.php file:

 <form action="server.php" method="post" enctype="multipart/form-data">
        Upload a File:
        <input type="file" name="myfile" id="fileToUpload">
        <input type="submit" name="submit" value="Upload File Now" >
    </form>

and the server. php file:

   <?php
if (isset($_FILES['myimage']['tmp_image'])) {
    $path = "uploads/".$_FILES['myimage']['name'];
    move_uploaded_file($_FILES['myimage']['tmp_image'], $path);
}


$target_url = "http://endpoint.ext/api/img";

$post = array('avatar'=> $path);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result=curl_exec ($ch);
curl_close ($ch);
?>

with this code, the script only success to uploads but did not send to endpoint, any one can help me on this :(

And Here is some more debugging info:

Array ( [myfile] => Array ( [name] => detail-rotate.jpg [type] => image/jpeg [tmp_name] => E:\xampp\tmp\phpDCB6.tmp [error] => 0 [size] => 553013 ) ) Array ( [submit] => Upload File Now )

Big Thanks

1 Answers1

0

Try using FTP rather than CURL; you can't just send data to a host and hope they accept it and know how to process it.

Thrallix
  • 699
  • 5
  • 20