开发者

move_uploaded_file() not working as expected (i.e at all) in PHP

using this line

$file_move = move_uploaded_file($_FILES['uploadedfile']['tmp_name'],
                                plugins_url('/css', __FILE__));

returns:

move_uploaded_file(http://lo开发者_Python百科calhost/*) [function.move-uploaded-file]: failed to open stream: HTTP wrapper does not support writeable connections in /Applications/MAMP/htdocs/***/as_settings.php on line 60

I have checked both arguments, and they are correct. I'm new to this side of coding, what have I missed?

---EDIT

In response to answers, have changed code to:

$dir = ABSPATH . 'wp-content/plugins/app-switcher/css';
$file = $_FILES['uploadedfile']['tmp_name'];
$file_move = move_uploaded_file($file,$dir);

Now my error response is:

Warning: move_uploaded_file(/Applications/MAMP/htdocs//wp-content/plugins/app-switcher/css/) [function.move-uploaded-file]: failed to open stream: Is a directory in /Applications/MAMP/htdocs//wp-content/plugins/app-switcher/as_settings.php on line 61


The error message is pretty obvious, your destination file should be a path, not a URL


You can't use a http:// URL as the target for move_uploaded_file(). You need to use a file path.

You're not saying what framework you are using, but it may have a counterpart to plugins_url() that returns a file path.


second parameter should not be URL


It's still obvious.
you have to pass a filename, not directory to this function

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜