I an creating a custom plugin that used shortcodes.. then it will have a feature that will upload files and stores it in wp-content/uploads/
directory.. but it seems I got an error..
Warning: move_uploaded_file(http://mysitecom/wp-content/uploads/myfiles/1991117- DriverLiscence.jpg): failed to open stream: HTTP wrapper does not support writeable connections in /home/user/public_html/mysite/wp-content/plugins/myplugin/functions.php on line 1266
Warning: move_uploaded_file(): Unable to move '/tmp/phpOOkdNJ' to 'http://mysitecom/wp-content/uploads/myfiles/1991117-DriverLiscence.jpg' in /home/user/public_html/mysite/wp-content/plugins/myplugin/functions.php on line 1266
this is the code:
$upload_dir = wp_upload_dir();
$wp_upload_url =$upload_dir['baseurl'];
$uploaddir = $wp_upload_url."/myfiles/";
$temp = explode(".",$_FILES[$file_uploaded]["name"]);
$newfilename = $contactID. '-'. $type . '.' .end($temp);
$uploadfile = $uploaddir . $newfilename;
if (move_uploaded_file($_FILES[$file_uploaded]['tmp_name'], $uploadfile)) {
echo 'success';
}
ny question is that, how can I get the exact path of the /wp-content/uploads/myfiles/
so that I can upload files?