Jump to content

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


dlebowski
Go to solution Solved by Ch0cu3r,

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.

Link to comment
Share on other sites

  • Solution

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.

Edited by Ch0cu3r
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.