简体   繁体   中英

Media file uploads go to /wp-content instead of /wp/wp-content in a subdirectory-installed instance of WordPress

Problem

Can't get Media upload files to drop into the right directory in a subdirectory-installed WordPress. What is the appropriate way to...

  1. Correct the path problem for future uploads
  2. Correct any pre-existing hard-coded references in the database with the wrong path

Symptoms

  • wp-content exists in both /wp-content and /wp/wp-content
  • Uploads to the Media tab in WordPress go to /wp-content/uploads/2018/06
  • Blank thumbnails are shown in the Media tab for images that all reference something like /wp/wp-content/uploads/2018/06/some_image_name.jpg
  • Drag and drop upload to the WordPress Media tab often results in http error

Environment

  • WordPress core and all files are installed in the /wp subdirectory
  • Settings > WordPress Address (URL) = https://www.example.com/wp
  • Settings > Site Address (URL) = https://www.example.com/wp
  • The database row for upload_path (within wp_options table) = /home/user/public_html/wp-content/uploads (but want it in wp subdirecty)
  • Web Hosting = GoDaddy Economy Linux Hosting with cPanel
  • PHP version = 7.1
  • memory_limit = 512M
  • post_max_size = 128M
  • upload_max_filesize = 1G
  • Relavant PHP extensions enabled = imagick, gd

It turns out that when this happens there's an absolute path that needs to be updated in the database. I found this out from this post...

http://kb.enoi.se/i-can-not-upload-images-to-my-wordpress-site-after-moving-it/

In short look in the wp_options table for and edit the row where the column name option_name = upload_path . Then change the option_value from the absolute path to have the correct subdirectory path. It will be something like...

/home/username/public_html/wp-content/uploads

Change it to to have your correct subdirectory, in my case wp ..

/home/username/public_html/wp/wp-content/uploads

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM