【问题标题】:Using c_url upload file to remote host, file name is incorrect使用 c_url 上传文件到远程主机,文件名不正确
【发布时间】:2010-12-01 06:18:55
【问题描述】:

使用 c_url 上传文件到远程主机。这是我的代码。

 <?php

/* http://localhost/upload.php:
print_r($_POST);
print_r($_FILES);
*/

$ch = curl_init();

$data = array('name' => 'Foo', 'file' => '@/home/autouvl/public_html/asmallorange/log.txt');

curl_setopt($ch, CURLOPT_URL, 'http://www.test.com/test/receivefile.aspx');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

echo(curl_exec($ch));
?> 

问题:在我的 receivefile.aspx 中。我得到的文件名是"/home/autouvl/public_html/asmallorange/log.txt"。但我希望它应该是“log.txt”,而不是完整路径。文件可以成功上传,但文件名不正确。

我的代码有什么问题?

谢谢!

【问题讨论】:

    标签: php curl upload filenames filepath


    【解决方案1】:
    $data = array('name' => 'Foo', 'file' => '@/home/autouvl/public_html/asmallorange/log.txt;filename=log.txt');
    

    【讨论】:

    • 非常感谢。作为我的测试,似乎效果不佳。我已经解决了我的问题,我构建了帖子正文。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 2017-08-27
    • 2017-01-15
    • 2012-07-11
    • 2017-09-09
    • 2014-05-15
    • 1970-01-01
    相关资源
    最近更新 更多