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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度