使用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”,而不是完整路径。除了文件名不正确外,文件可以成功上传。
我的代码出了什么问题?
谢谢你!
Using c_url upload file to remote host. here is my code.
<?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));
?>
Question: in my receivefile.aspx. I got the file name is "/home/autouvl/public_html/asmallorange/log.txt"
. but I want It should be "log.txt", not full path. file can be uploaded successfully except incorrect file name.
what's wrong in my code?
thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)