The MU forums have moved to

Import attachment "Remote file is incorrect size" - THIS IS A BUG (I fixed it) (10 posts)

  1. RiniBoo
    Posted 14 years ago #

    This can be replicated in Windows running Apache.

    I exported the XML file from regular wordpress and tried to import to Wordpress MU with the "Download and import file attachments" checked.

    The posts imported successfully, however all the JPGs were not imported, and I got the error "Remote file is incorrect size" for every file.

    I traced it to /wp-admin/import/wordpress.php (line 587), and found that:

    filesize($upload['file']) is ALWAYS ZERO ??!!!
    $headers['content-length'] is correct size
    $upload['file'] has C:\webroot\\blog/wp-content/blogs.dir/2/files//2008/01/DSC01023.jpg

    As you can see, there is "//" in the path, and it is mixed with forward and backward slashes.

    That was the reason why it failed, however, when I monitored the file folder during the import, I saw the files were actually written to the file system, and then got deleted ("unlink" the file)

    To fix this:

    /wp-admin/import/wordpress.php (line 582) insert these:

    $upload['file'] = str_replace("//", "/", $upload['file']);
    $upload['file'] = str_replace("/", "\\", $upload['file']);

    and problem is fixed.

  2. tdjcbe
    Posted 14 years ago #

    You need to bring this up on trac:

  3. andrea_r
    Posted 14 years ago #

    It shoudl probably be brought up in the regualr WP trac too, with no mention of mu.

    The export file also has outstanding unfixed issues in trac as well.

    Frankly, it's quite a mess.

  4. tdjcbe
    Posted 14 years ago #

    Thank you though for working on the problem.

  5. MrBrian
    Posted 14 years ago #

    I'm not positive, but I think windows treats two slashes ("//") in the directory different than linux, so a note to everyone that this should only affect Windows.

  6. andreu
    Posted 13 years ago #


    I have the same problem but your solution doesn't work for me.
    Probably my Wordpress version (2.7.1) is different than yours when you tried it?

    Thank you in advance!

  7. andreu
    Posted 13 years ago #

    I realised that my files URL is not correct because it doesn't include the year and month of the post. I think the error is related to the change of the image's URL. Those where and now are

    I'll try more things...

  8. VentureMaker
    Posted 13 years ago #

    andreu, wrong forum.
    You should be here:

  9. andrea_r
    Posted 13 years ago #

    No, he needs the wordpress.COM support forum.

  10. rodrigosprimo
    Posted 13 years ago #

    Almost the same issue here. I was trying to import a Wordpress 2.7.1 blog to a Wordpress-MU 2.7.1 running on a Linux box with Apache.

    I got the error "Remote file is incorrect size" for all my attachments.

    The $upload['file'] got the double slash but without the year and month directory. For example:


    Instead of:


    To be able to import I did a really dirt workaround. I commented out the lines below (that check the file size):

    elseif ( isset($headers['content-length']) && filesize($upload['file']) != $headers['content-length'] ) {
        return new WP_Error( 'import_file_error', __('Remote file is incorrect size') );

    With this I was able to complete the import process with all the attachments but now they are all on the root of the directory blogs.dir/ID/files/

    I tested the same dump file in a fresh Wordpress 2.7.1 installation and there was no problem with the attachments.

About this Topic

  • Started 14 years ago by RiniBoo
  • Latest reply from rodrigosprimo