0

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

我的代码有什么问题?

谢谢你!

4

1 回答 1

0
$data = array('name' => 'Foo', 'file' => '@/home/autouvl/public_html/asmallorange/log.txt;filename=log.txt');
于 2010-12-01T10:01:32.393 回答