Cannot upload images to self hosted site

In an attempt to troubleshoot :

Try this :
https://wordpress.org/plugins/add-from-server/

Run this :
https://wordpress.org/plugins/health-check/

chmod the uploads/ directory to 777

Make sure the user executing the WordPress belongs to the apache group.

Check with php 5.6

Create an info.php file and check it out in your browser :
<?php phpinfo(); ?>
Make sure that this output reads :
“file_uploads = ”

Add this to your config, and look at your debug.log logs :

define(‘WP_DEBUG’, true); 
define( ‘WP_DEBUG_LOG’, true ); 
define( ‘WP_DEBUG_DISPLAY’, true );

Do you have WooCommerce installed ?

Is there no message being thrown from the handler ??
https://developer.wordpress.org/reference/functions/wp_handle_upload_error/

Thank you for your response! I haven’t tested anything else yet, busy day for me, but I did have time to try the “Add from Server” plugin. It worked and I was able to upload a file and publish it to my page!

It doesn’t solve the root issue of not being able to use the core media library upload feature though so I can’t mark it as resolved yet. I’m worried about using an unsupported plugin as a workaround, so I’m going to try some of your other suggestions when I have a chance later tonight and continue working on getting the core upload feature working. Thank you for this though! If nothing else I can at least slap the metaphorical duct tape on and continue developing the website while I work on this back end issue.

I already had the WordPress Debug logs congigured as you suggested, they only show <PHP Notice: Trying to access array offset on value of type null in /var/www/my-virtual-host/html/wp-admin/includs/file.php, ~/wp-admin/async-uploads.php, and ~/wp-admin/includes/ajax-actions.php> All of the array values pertain to the name of the file that I’m trying to upload. Nothing says anything about the actual issue.

Site health was already enabled and told me nothing. The only listed issues are plugins that I disabled to test things and the WP_DEBUG_LOG issue it throws because it’s potentially accessible through your browser.

I’ve tried chmod 777, 755, 750. No changes throughout.

Everything should be owned by apache:apache. I’m able to add themes and do everything else on the site.

Before I rolled back to PHP 5.6 I wanted to check the info.php file you mentioned. Didn’t think to use it as a troubleshooting method, I’ll have to remember that.

This is the strangest thing. I’m looking at the info.php webpage and it told me that file uploads are off. However in php.ini, <file_uploads = On> is correctly configured. It also says that it is looking for additional files in /etc/php.d. I check there and find this small additional configuration file: security.ini.

Lo and behold, file_uploads = Off in this file and it was overriding my default php.ini config.

THANK YOU for the idea of using info.php to troubleshoot. I would never have caught this otherwise. I’m still relatively new to Linux and having a blast tripping over myself like this every other day.

  • This reply was modified 2 days, 9 hours ago by jflanakin.

This is good news then.
The more you use a LAMP, the more you will learn to mistrust the php.ini file.

There are too many variables and privileges that have access to take precedence over that file.



Source link