• amirforum

    (@amirforum)


    Hi
    I have an online shop in wordpress. I want to use another folder outside wp-contents for my products image files and don’t like the uploads/ year and months folder making of wordpress. So the final link to the uploaded picture will be: mysite.com/pics/pic1.jpg

    What I did:
    1. from Setting > Media > I un-tick the Organize my uploads into month- and year-based folders
    2. in wp-config.php I added this in last line:
    define( ‘UPLOADS’, ‘pics’ );
    3. uploaded a picture for a product.

    It is uploaded, but wordpress can’t show that picture and its URL is shown like this:
    https://mysite.com/wp-content/uploads//home/mysitecpaneluser/public_html/pics/pic1.jpg

    I see the picture in correct folder with other required sizes which are auto generated. But the problem is the URL. it can’t be shown in product tab and also in media library.

    I searched some forums and no one declared a problem like this. some just mentioned the folder permissions which I tested (like 755 and 744) but no success.

    the URL is totally wrong.

    If I use a folder in wp-contents, it will be OK, but outside wp-contents generate that URL problem

Viewing 5 replies - 1 through 5 (of 5 total)
  • 2. in wp-config.php I added this in last line:
    define( ‘UPLOADS’, ‘pics’ );

    If you look at the wp-config.php, you’ll see this comment line:

    /* That's all, stop editing! Happy publishing. */

    All the code you put into the wp-config.php should be ABOVE this line, and never at the very end of the file as you did (unless you really know what you’re doing).

    So move the code up above the above comment line, and this should work.

    Aoba Momouchi

    (@aoixtreme)

    In another way, access to your “/wp-admin/options.php” and you find “upload_path” and “upload_url_path” text fields.

    And specify “pics” for “upload_path” and “https://mysite.com/pics” for “upload_url_path”.

    n another way, access to your “/wp-admin/options.php” and you find “upload_path” and “upload_url_path” text fields.

    And specify “pics” for “upload_path” and “https://mysite.com/pics” for “upload_url_path”.

    I’m afraid, but this will only make a bad situation even worse.

    Remember, OP currently has a bad config. This works as an alternative to defining the path in the wp-config.php file. But making this change with the bad config in place only seems to worsen the problem (at least in my test, unless I missed something — as I often do ?? ).

    @gappiah
    Thanks.
    Bad config may cause any problem.
    Be sure to use this method(options.php) at your own risk.

    Thread Starter amirforum

    (@amirforum)

    @gappiah
    Thanks for your answer. It worked.
    There was also another problem:
    This is wrong: define( ‘UPLOADS’, ‘pics’ );
    and should be like this: define( ‘UPLOADS’, ”.’pics’ );

    The above solution worked for a new pic that I uploaded to my site.

    But now I have a bigger problem. For the hundred of previously uploaded pictures, media library doesn’t show the pictures and when I click on one of them the url is like: https://mysite.com/pics/2020/04/somepic.jpg
    the “/pics” here for old pictures is wrong.

    any idea?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change Media Upload Directory’ is closed to new replies.