0

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?

Edited by psyb0rg: n/a

3
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by gieseni
0

Is there a way to check the whole POST data BEFORE it is posted?

0

you may put on your curl : curl_setopt($ch, CURLOPT_HEADER, 1);
try to change : curl_setopt($ch, CURLOPT_HEADER, TRUE);

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.