0

I am using the following code to auto update the file to server by using windows scheduled jobs

<?php
   $url="http://example.com/uploadtest";
    $p_date = date('Y_m_d');

    $files = realpath("../daily_backup/$p_date.txt");  //  file name
    echo $files;
    $data=array();
    $data['file']="@".$files;

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
    $response = curl_exec($ch);
    print_r ($response);
    print_r (curl_getinfo($ch));
    echo $response. "Done";

?>

And In my uploadlast page the code is

echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
move_uploaded_file($_FILES["file"]["tmp_name"],
"xml_data/" . $_FILES["file"]["name"]);
echo "Uploaded";

The OutPut Should be "Uploaded Done". but in my client system "Done". *There was no errors* i check the path also

But i above code works in my system . what i am missing in my client system ?.

Note: I'm using xampp in my client system.

The result of the $ch is

  Array ( [url] => http://example.com/uploadtest [content_type] => [http_code] => 0
 [header_size] => 0 [request_size] => 0 [filetime] => -1 [ssl_verify_result] => 0 redirect_count] => 0 [total_time] => 0 [namelookup_time] => 0 [connect_time] => 0 
[pretransfer_time] => 0 [size_upload] => 0 [size_download] => 0 [speed_download] => 0 
[speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 
[starttransfer_time] => 0 [redirect_time] => 0 [certinfo] => Array ( ) 
[primary_ip] => [primary_port] => 0 [local_ip] => [local_port] => 0 [redirect_url] => ) 
vijaykumar
  • 4,658
  • 6
  • 37
  • 54

1 Answers1

0

Debug the curl object using the function curl_getinfo() (http://us3.php.net/curl_getinfo)

  • i Updated the curl_getinfo result – vijaykumar Nov 11 '13 at 06:50
  • You can see the http_code] => 0 returned in info ( 0= failed). please make sure your able to connect the http://example.com/uploadtest . you can confirm from browser window also. – SATISH A Nov 11 '13 at 06:57