1

我正在使用 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
4

1 回答 1

2

$target应该是一条路径

move_uploaded_file的第二个参数应该是一个路径。错误消息如下:

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

因此,现在$target是一个 url。提供一个有效的文件路径,$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/');
}

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

于 2013-05-21T07:17:24.713 回答