Reputation: 30823
using this line
$file_move = move_uploaded_file($_FILES['uploadedfile']['tmp_name'],
plugins_url('/css', __FILE__));
returns:
move_uploaded_file(http://localhost/*) [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
Upvotes: 1
Views: 7184
Reputation: 158005
It's still obvious.
you have to pass a filename, not directory to this function
Upvotes: 0
Reputation: 6159
The error message is pretty obvious, your destination file should be a path, not a URL
Upvotes: 17
Reputation: 449813
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.
Upvotes: 2