为什么move_uploaded_file不适合我

时间:2013-05-20 17:50:51

标签: php

我正在使用mysqli程序编程,而move_uploaded_file现在对我不起作用。我现在在当地工作,所以我有所需的所有特权。

if(move_uploaded_file($_FILES['image']['tmp_name'], $target)){ 
    redirectTo($settings['siteDir'] . 'admin/cpanel/');
}

我以前从未遇到过任何问题。这是mysqli搞砸了吗? 这些是我得到的错误

Warning: move_uploaded_file(http://localhost/websites/mugendo.ie/images/uploads/mai.jpg) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections in D:\xampp\htdocs\websites\mugendo.ie\admin\addnews.php on line 29

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\xampp\tmp\php1498.tmp' to 'http://localhost/websites/mugendo.ie/images/uploads/mai.jpg' in D:\xampp\htdocs\websites\mugendo.ie\admin\addnews.php on line 29

1 个答案:

答案 0 :(得分:2)

$target应该是路径

move_uploaded_file的第二个参数应该是一条路径。错误消息显示为:

  

无法移动到http://localhost/websites/mugendo.ie/images/uploads/mai.jpg

因此,现在$target是一个网址。为$target提供有效的文件路径,它将起作用,或提供不同的错误消息,例如:

$target = 'D:\xampp\htdocs\websites\mugendo.ie\images\uploads\mai.jpg';
if(move_uploaded_file($_FILES['image']['tmp_name'], $target)){ 
    redirectTo($settings['siteDir'] . 'admin/cpanel/');
}

如果错误日志失败,请务必阅读错误日志 - 错误消息将准确说明需要纠正的内容才能成功。