Jump to content

cURL Image Upload Works on Local XAMPP, But Not Web Server


dlebowski

Recommended Posts

    
    $account="54646456456464";
    $station= "12345";
    $options="11-1";
    $image="C:/Desktop/Sample Images/usco1.jpg";
    
    
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"http://dfdgfsfs.com/kgdfgd.php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
            'image' => '@'.$image, 'account' => $account, 'station' => $station, 'options' => $options));


$postResult = curl_exec($ch);


curl_close ($ch);

$xmlobj = simplexml_load_string($postResult);

echo (string)$xmlobj->ID->attributes()->value;
echo (string)$xmlobj->FullName->attributes()->value;

All, I have spend days trying to figure this out without any luck.  I am now in crisis mode.  I need to get this working asap.  The following code works perfect on my local xampp machine.  As soon as I upload it to my web server, I don't get any data back.  I have narrowed it down to the image i am trying to send is not being received properly.  Thanks in advance.

The following is local file path for your PC and not the server

$image="C:/Desktop/Sample Images/usco1.jpg";

usco1.jpg needs to be located on the server you are running the code from. PHP cannot access remote users file systems.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.