WordPress.org

Support

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

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

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