2010-12-01 40 views
0

使用c_url上傳文件到遠程主機。這是我的代碼。使用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」,而不是完整的路徑。文件可以成功上傳,除了不正確的文件名。

我的代碼有什麼問題?

謝謝!

回答

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

非常感謝。作爲我的測試,似乎它沒有效果。我已經解決了我的問題,我仔細地構建了後體。 – Sean 2010-12-03 04:29:47

相關問題