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

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?