WordPress.org

Ready to get started?Download WordPress

Forums

uploaded media going to different directory than listed in settings-misc (21 posts)

  1. pmfox
    Member
    Posted 6 years ago #

    I've set up a new site for a friend and when it uploads the file it uploads to wp-admin/(whatever I have listed in settings-misc).

    For example:
    I left the default upload directory of wp-content/uploads.
    When I upload the picture or file it doesn't show the picture but the file uploaded fine.
    Then, when I go in with my FTP client to find where it is, I find the file stored in wp-admin/wp-content/uploads. However, the link in the media library shows it thinks the image or file is in the wp-content/uploads.

    Any idea what/how to fix this? I haven't been able to find this in any of the other forum comments & questions.

    Thanks.

  2. pmfox
    Member
    Posted 6 years ago #

    Update:
    I have uninstalled and started with a new empty MySQL database. Cleared cache and followed all instructions in a previous topic that solved other problems, http://wordpress.org/support/topic/164999?replies=1.
    When I upload a file (image and documents) it's still going to the wp-admin directory with the subdirectory of whatever I put into the setting-miscellaneous.
    Example I have the default directory of wp-content/uploads in the settings.
    When I use the media uploader, it uploads to:
    wp-admin/wp-content/uploads
    and cannot display or find the file.

    I've installed this on several sites and haven't had any issues like this before. Could it be the host?

    Any help would be deeply appreciated.

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Do you have something strange in your wp-config? The line in question should look like this:
    define('ABSPATH', dirname(__FILE__).'/');

    If the ABSPATH is not getting set correctly, you might have this effect.

  4. pmfox
    Member
    Posted 6 years ago #

    That's exactly how it reads. Nothings changed.
    Thanks for the quick reply.

  5. Josh Leuze
    Member
    Posted 6 years ago #

    pmfox, I am having the same exact problem with a couple of my blogs.

    I have found a few of other people on this forum with the same problem, and submitted a ticket about it. But as far as I know, no one has been able to fix this issue.

    But I did come up with a work-around to be able to upload files until it is fixed.

    Do you have something strange in your wp-config?

    Otto42, I check this line in my wp-config, and mine was also correct. If you have any other suggestions, I'd be grateful for them!

  6. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Add this code to your theme's footer.php:

    echo '<!--';
    print_r(wp_upload_dir());
    echo '-->';

    Then load your page, view the source, find the bit added to the bottom of the page, and tell me what the result is here. Afterwards, delete the new lines from your footer.php. No need to have it there all the time, this is just for debugging purposes.

    Also, reupload all the files in your wp-includes directory with fresh copies.

  7. Josh Leuze
    Member
    Posted 6 years ago #

    Otto, here are the results that I got:

    Array
    (
        [path] => wp-content/uploads
        [url] => http://www.MYDOMAIN.com/wp-admin/wp-content/uploads
        [subdir] =>
        [error] =>
    )

    Bear in mind that I have added the "Full URL path to files" in Misc. Settings, so that I can insert the uploaded images into posts and not have the links break.

    I have reuploaded all of the files in wp-includes and wp-admin, and I have tried reinstalling a fresh copy of 2.5.1 from scratch with a new database. My results have always been the same.

  8. pmfox
    Member
    Posted 6 years ago #

    Otto,
    I have the same as jleuze. Except I won't use the workaround with this person because I don't want the people using it to have anything to do with the wp-admin directory.

    I'm in the process of setting up a subdomain (xyz.mydomain.com) and a different directory on their host to upload WP into, again. Starting with a new MySQL database, again. And I'll let you know the results. However, I won't get to it for a day or two. (don't hold your breath. This will be the third time doing this.)

    If it does it a third time I'm telling them to switch webhosts because this is the only one I've had this issue with. I don't want to risk the wp-admin directory with the workaround that jleuze found.

    Thanks again for the help.

  9. Josh Leuze
    Member
    Posted 6 years ago #

    I don't want to risk the wp-admin directory with the workaround that jleuze found.

    Yes, considering the number of authors that contribute to the blogs that I am having this problem with, I am not thrilled about the risks either!

    And I am also preparing to move my problem installs to a different webhost, just in case...

  10. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    [path] => wp-content/uploads

    That's wrong. That should be the full path. It doesn't make any sense that it's only a partial path.

    Here's what I get, for example:

    Array
    (
        [path] => /home/..(snip).../html/blog/wp-content/uploads/2008/06
        [url] => http://ottodestruct.com/blog/wp-content/uploads/2008/06
        [subdir] => /2008/06
        [error] =>
    )

    So that's your problem. The first part of the path is set by the ABSPATH variable, which is why I asked about that.

    Do you have any plugins? Deactivate them, see if the problem continues.

    Also, stick this in a new PHP file, run it on your website, see what the result is:
    <?php echo __FILE__; ?>

  11. Josh Leuze
    Member
    Posted 6 years ago #

    Otto, I deactivated my plugins(Add Lightbox, Akismet, Auto-hyperlink URLs, Brian's Latest Comments, Comments Notifier, Google XML Sitemaps, Lightbox 2, No Flash Uploader, StatPress, WP-phpBB, WP YouTube) and re-ran that snippet, my results were the same:

    Array
    (
        [path] => wp-content/uploads
        [url] => http://www.MYDOMAIN.com/wp-admin/wp-content/uploads
        [subdir] =>
        [error] =>
    )

    I created a new PHP file as you directed, and ran it on my website:

    /data/14/1/151/125/1314940/user/1408449/htdocs/test.php
  12. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Okay, that simply does not make any damn sense... I have no idea where to start.

    Try this in the theme's footer:

    echo '<!--';
    echo "ABSPATH: ".ABSPATH."\n";
    echo "UPLOAD: ".get_option( 'upload_path' )."\n";
    echo "PATH:".path_join( ABSPATH,get_option( 'upload_path' ) )."\n";
    print_r(wp_upload_dir());
    echo '-->';
  13. Josh Leuze
    Member
    Posted 6 years ago #

    Here are my results:

    <!--ABSPATH: /data/14/1/151/125/1314940/user/1408449/htdocs/
    UPLOAD: wp-content/uploads
    Array
    (
        [path] => wp-content/uploads
        [url] => http://www.MYDOMAIN.com/wp-admin/wp-content/uploads
        [subdir] =>
        [error] =>
    )
    -->
  14. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Whoa, you are missing something there. What about this line?
    echo "PATH:".path_join( ABSPATH,get_option( 'upload_path' ) )."\n";

    You should have a "PATH:" in your output as well.

  15. Josh Leuze
    Member
    Posted 6 years ago #

    Nothing too promising here:

    PATH:wp-content/uploads
  16. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Actually, that's good. The path_join did not give the correct result. It *should* have given you
    /data/14/1/151/125/1314940/user/1408449/htdocs/wp-content/uploads

    That tells us where the problem lies.

    Try this as a test:
    echo "PATH: ".path_join( '/data/','14');

    What's the result?

    Also, does the wp-content/uploads directory actually exist? Make sure that it does.

    Also also, triple check that the wp-includes/functions.php file is the correct version, from the latest download of WordPress. Quadruple check it, in fact.

  17. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    Oh, and a fix/workaround suggests itself now. Instead of using just wp-content/uploads on the Settings->Misc screen, use the full path I just gave you:
    /data/14/1/151/125/1314940/user/1408449/htdocs/wp-content/uploads

    Remove the URL fix you made at the same time.

  18. Josh Leuze
    Member
    Posted 6 years ago #

    The result is:

    PATH: 14

    does the wp-content/uploads directory actually exist?

    Yes, the directory exists.

    triple check that the wp-includes/functions.php file is the correct version

    I downloaded the latest version of WordPress and compared that functions.php to mine. They were identical, but I replaced it with the fresh version.

  19. Josh Leuze
    Member
    Posted 6 years ago #

    use the full path I just gave you:
    /data/14/1/151/125/1314940/user/1408449/htdocs/wp-content/uploads

    I replaced "wp-content/uploads" with "/data/14/1/151/125/1314940/user/1408449/htdocs/wp-content/uploads", and removed "http://www.MYDOMAIN.com/wp-admin/wp-content/uploads" from my full path and left that field blank.

    But when I save the changes, it reverts "/data/14/1/151/125/1314940/user/1408449/htdocs/wp-content/uploads" back to "wp-content/uploads". I tried that a couple of times, but it wouldn't take.

  20. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    The result is:
    PATH: 14

    Well, I don't understand why it gives you the wrong answers, but that is indeed your problem, in the path_join function.

    I'll bring it to the attention of trac, see what they make of it.
    http://trac.wordpress.org/ticket/5953

  21. Josh Leuze
    Member
    Posted 6 years ago #

    Thanks for your assistance Otto, it's much appreciated!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.