wp_handle_upload – The uploaded file could not be moved to wp-content/uploads/20
-
This is the code I am using to upload the file to WordPress
require $_SERVER['DOCUMENT_ROOT'] . "/wp-load.php"; require $_SERVER['DOCUMENT_ROOT'] . "/wp-admin/includes/file.php"; define(‘WP_DEBUG’, true); $filename = "test.png"; $tmpFile = download_url("https://url.com/testing/crop/".$filename); chmod($tmpFile, 0755); $mimeType = wp_check_filetype($_SERVER['DOCUMENT_ROOT'] . '/testing/crop/'.$filename); $file_array = array( 'file' => $_SERVER['DOCUMENT_ROOT'] . '/testing/crop/'.$filename, 'url' => $_SERVER['DOCUMENT_ROOT'] . '/testing/crop/'.$filename, 'type' => $mimeType['type'], 'size' => filesize($_SERVER['DOCUMENT_ROOT'] . '/testing/crop/'.$filename), 'name' => $filename, 'tmp_name' => $tmpFile ); $image = wp_handle_upload($file_array, array('test_form' => FALSE, 'test_upload' => FALSE, 'test_type' => FALSE)); print_r($file_array); print_r($image); unlink($tmpFile);
This is the error I am getting “The uploaded file could not be moved to /home/xxxx/public_html/wp-content/uploads/2012/09.”
What I am trying to do is have a small PHP script outside of WordPress upload images to its Media Library and then post it however at this point I am getting stuck at the uploading stage.
All the permissions are correct as I am able to upload fine through the WordPress admin area.
Any help is much appreciated.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘wp_handle_upload – The uploaded file could not be moved to wp-content/uploads/20’ is closed to new replies.