I'm trying to upload a file to a remote server using curl.
The server requires that the file contents should be in the post body and the file name should be in the header.
This is the code I', using :
$fp = fopen($fileLocation, "r"); $ch = curl_init(); curl_setopt($ch, CURLOPT_INFILE, $fp); curl_setopt($ch, CURLOPT_INFILESIZE, filesize($fileLocation)); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_UPLOAD, 1); curl_setopt($ch, CURLOPT_URL, $destinationServer); $header = array( "fileName: $fileID" ); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); $response = curl_exec($ch);
The above code sends the file OK but the header received at the server does not contain the fileName value.
Whats wrong here?