In this post, I will describe an instance where I was transferring a WordPress site from one cPanel to another. After I moved the site from one server to another I got the following error:
Warning: fopen(/home/moreread/public_html/wp-content/themes/directorypress/thumbs/makemusicviral.wordpress.com.jpg) [function.fopen]: failed to open stream: No such file or directory in /home/morereader/public_html/wp-content/themes/directorypress/PPT/class/class_premiumpress.php on line 944
Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/morereader/public_html/wp-content/themes/directorypress/PPT/class/class_premiumpress.php on line 945
Warning: fclose() expects parameter 1 to be resource, boolean given in /home/morereader/public_html/wp-content/themes/directorypress/PPT/class/class_premiumpress.php on line 946
To fix the error: While I was moving my site I forgot to change the path in the new cPanel location.
So I changed the path of:
/home/moreread/public_html/wp-content/themes/directorypress/thumbs/
to
/home/morereader/public_html/wp-content/themes/directorypress/thumbs/
Here moreread was the old cPanel username for the site and morereader is the new cPanel user name.
There can be many reasons for this error to occur. However, I am describing two basic troubleshooting methods to fix this error in your WordPress blog.
Troubleshooting:
1) When you are troubleshooting fopen, fwrite, fclose errors in WordPress blog or for any other CMS make sure that the path of the file which is pointing to that location exists in new installation. If the file doesn’t exist in the specified location you need to add the file or the folder which ever is missing.
2) If the location exists then make sure that you change the file permissions of the specified folder in the error to: chmod 777 or 755. (whichever works for your server). You have to make the folder writable.
I hope these troubleshooting steps are helpful if you are stuck in the fopen, fwrite, and fclose errors in your WordPress blog.