dsjq62428 2015-11-06 18:58
浏览 148
已采纳

从CURL文件上载请求中删除文件路径

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
  • 写回答

1条回答 默认 最新

  • dowaw80220 2015-11-06 19:09
    关注

    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');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?