Support » Plugin: Add From Server » [Plugin: Add From Server] Solution: Incorrect file URL in database after import

  • Resolved denderli

    (@denderli)


    I came across a problem while using this plugin. I was importing some files that were already within the wp-content/uploads directory structure but were nested a couple of directories deeper. The files imported just fine into the media library and the correct URL for the file showed up in the media library as well.

    However, when trying to embed the file in a page or post for playback the file could not be found. Below is what I found and also a fix to correct the problem.

    Imported URL as seen by the media library:

    [audio src="http://localhost/wordpress/wp-content/uploads/artist_name/sectiontitle/special_module_1_files/audio.mp3" /]

    The actual URL as it had been saved to the database:

    [audio src="http://localhost/wordpress/wp-content/uploads/audio.mp3" /]

    The “fix” for this is a very simple one.

    Locate the file: add-from-server.php

    If you have a good code editor the code can be found at lines 207 and 208.

    If you don’t have a good editor, do a search for the following:

    // Compute the URL
    $url = $uploads[‘url’] . ‘/’ . rawurlencode($filename);

    Comment out the second line as such…

    // Compute the URL
    //$url = $uploads[‘url’] . ‘/’ . rawurlencode($filename);

    Save your file and your URL’s that are entered into the database will retain their original path. I haven’t tested this for files that lie outside of the wp-content/uploads directory, but this resolved my issue.

Viewing 4 replies - 1 through 4 (of 4 total)
  • denderli

    (@denderli)

    Author’s Note:

    This will not correct URL’s that already exist in the database. You will either have to do that manually, or remove the database entry and re-import.

    denderli

    (@denderli)

    Author’s Note:

    Alternatively, you could use this wonderful plugin to aide you in correcting the url’s in the guid and meta_value fields.

    Search and Replace:
    http://wordpress.org/extend/plugins/search-and-replace/

    I can confirm this problem exists and that the fix works.

    Plugin Author Dion Hulse

    (@dd32)

    I believe this was fixed in 3.2.0.1, Specifically GUID’s were receiving the incorrect URL’s. Any plugin relying upon GUID’s to determine the filepath is broken to start with..

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Add From Server] Solution: Incorrect file URL in database after import’ is closed to new replies.