Tesmen
Tesmen

Reputation: 589

Remove file path from CURL file upload request

I am using CURL to POST upload files on a web-service. Server returns a XML with file name with which it puts file in a storage DB for further processing. Simplified code below:

$post['uploadfile'] = new CurlFile('src/files/file.png', 'image/png');

$ch = curl_init($target_url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);

Server side code is unavailable for me, and the problem is that server returns me a path for the uploaded file like this:

src_files_file.png

I guess i have missed a field in request, that holds clear name for file. How could it be resolved to

file.png

Upvotes: 0

Views: 441

Answers (1)

Anton Ohorodnyk
Anton Ohorodnyk

Reputation: 883

I not sure that I fully understand your question, but I think you search third parameter in CurlFile constructor:

$post['uploadfile'] = new CurlFile('src/files/file.png', 'image/png', 'file.png');

Upvotes: 1

Related Questions