i am used the follow script what will upload an image by URL to wp, but it fails (debugging brings "The uploaded file could not be moved to wp-content/uploads/2016/03"). But i was wondering... the uploaded image is 778kb, upload_max_filesize in PHP-7 php.ini was 100M. On begin of week this function works fine, but since last two days (without changing anything) this will not work.

I used PHP Version 7.0.4-5 and the function loads per CLI-Script (a cronjob). The /etc/php/7.0/cli/php.ini upload_max_filesize was changed from 2M to 100M (also post_max_size from default to 100M). The rights on directory /tmp and /var/www/domain.tld/htdocs/wp-content/uploads are all right (chmod 0775). Both directories 2016 and 03 are chowned by www-data and have also the rights 0775.

The temporary file by download_url() exists also and are a correct jpg-file. I don't know anymore where i can look to find the error. I have test it also on a live server... the same error.

Here is the function:

function setThumbnail($postid,$img,$isPreview=false) {
    global $wpdb;
    if (is_wp_error($tmp)){
        return false;
        foreach($id->get_error_messages() as $err){
        return false;
    if($isPreview) {
    return $src;

The Problem was the @copy() in wp-includes/file.php class of wordpress. This will mask the real problem why the file could not copied (the rights on on htdocs was not ok). So the problem is fixed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.