[resolved] wp_handle_upload - The uploaded file could not be moved to wp-content/uploads/20 (2 posts)

  1. Rambomst
    Posted 3 years ago #

    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("http://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));

    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.

  2. Rambomst
    Posted 3 years ago #

    My question was answered here.

Topic Closed

This topic has been closed to new replies.

About this Topic