使用c_url上传文件到远程主机,文件名不正确

时间:2010-12-01 06:18:56

标签: php curl upload filenames filepath

使用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”,而不是完整路径。文件可以成功上传,文件名不正确。

我的代码有什么问题?

谢谢你!

1 个答案:

答案 0 :(得分:0)

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