Unexpected response from the server. The file may have been uploaded successfully. Check in the Media Library or reload the page

Update: updating WordOps with the command

wo update

appears to have solved the problem.

I did not update further with

wo stack upgrade

and

wo maintenance

as things are working OK and I don’t want to risk any incompatibilities arising out of the upgrades.

……………………………………………………..

This problem started with the WordOps VPS whenever I uploaded pdf files of a few MB in size. This is because the php.ini file has a limit and the system was timing out before the upload was complete.

According to https://www.php.net/manual/en/configuration.file.per-user.php, in addition to the main php.ini file, PHP scans for INI files in each directory, starting with the directory of the requested PHP file, and working its way up to the current document root (as set in $_SERVER[‘DOCUMENT_ROOT’]). In case the PHP file is outside the document root, only its directory is scanned.

PHP includes support for configuration INI files on a per-directory basis. These files are processed only by the CGI/FastCGI SAPI. This functionality obsoletes the PECL htscanner extension. If you are running PHP as Apache module, use .htaccess files for the same effect.

Creating a site-wise php.ini file has the advantage that it will not be overwritten by upgrades to the WordOps.

So, I created a .user.ini in the site root (/var/www/sitename/htdocs) and added the following directive in it

upload_max_filesize="100M"

Restart nginx with the command

 wo stack restart --nginx 

or restart the webstack with the command

wo stack restart --web 

Also restart the php7.4-fpm (check the version)

 sudo service php7.4-fpm reload 

Leave a Reply

Your email address will not be published. Required fields are marked *