I am having a peculiar issue with cURL on XAMPP 5.6.8. Using the below code, I am not able to send a file that does exist at the path specified in $tempPath
. I am thinking that the cURL library may be getting confused with my path that starts with c:\
.
My file is found here: C:\tempFolder\r_4878.tmp
On the linux server, using the exact same code, this does work using /mnt/temp/
. Why should there be a difference?
What might be breaking here?
Upload Code
$post = array( 'file_name' => $reportID, 'file_contents'=>'@'.$tempPath.'' );
$return = true;
# set the url that we need to use to upload to each server
$url = "http://server.corp/uploadServer.php";
# curl the file to the remote server
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HEADER, false );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_TIMEOUT, 240 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Accept: application/json' ));
# get the servers respone and decode the json response
$result = json_decode( curl_exec( $ch ) );
$t = array( $url, $tempPath, file_exists( $tempPath ), $result->success, $post, $result );
echo "\r\n".print_r( $t, true )."\r\n\r\n";
curl_close( $ch );
Remote Server
$output['file_exists'] = file_exists( $_FILES["file_contents"]["tmp_name"] );
$output['file_path'] = $fileName.".txt";
$output['tmp_name'] = $_FILES["file_contents"]["tmp_name"];
$output['success'] = move_uploaded_file( $_FILES["file_contents"]["tmp_name"], $fileName.".txt" );
Response
Array
(
[0] => http://server.corp/uploadServer.php
[1] => C:\tempFolder\r_4878.tmp
[2] => 1
[3] =>
[4] => Array
(
[file_name] => UnitTest25-felix
[file_contents] => @C:\tempFolder\r_4878.tmp
)
[5] => stdClass Object
(
[file_name] => UnitTest25-felix
[file_exists] =>
[file_path] => UnitTest25-felix.txt
[tmp_name] =>
[success] =>
[generationTime] => 9.70363616943E-5
)
)