Timthumb not showing images and throws “Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. ” error. [Solved]

timthumbRecently I faced a situation where the timthumb script was unable to crop the images and was throwing error messages. There are themes those still use timthumb even though its a bad practice to use in themes when we have already functions available in core WordPress. Anyway I had to fix the issue as I was not state to replace the timthumb functionality with core WordPress functions.

Here is the error message:

Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. 
File(/usr/local/apache/htdocs/wp-content/uploads/2014/02/nandankanan-national-park.jpg) 
is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) 
in /home/a9582221/public_html/wp-content/themes/kingsize/timthumb.php 
on line 862

This issue occurs in several hosts, mainly the free hosts available these days. So, the trick is to find where the $docRoot variable was set and set it to my public_html folder manually in my home directory. In my file it was on line number 825. I did the following…

// $docRoot = @$_SERVER['DOCUMENT_ROOT'];
$docRoot = '/home/a9582221/public_html';

Obviously the /a9582221/ would be your username.

Where to make this changes ??
Search for the file timthumb.php and make the above changes. Thats it. The issue got resolved now.


Posted

in

, ,

by

Comments

2 responses to “Timthumb not showing images and throws “Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. ” error. [Solved]”

  1. Paul Avatar

    Hi Subh, this worked great for me, thanks!

    1. Subharanjan Avatar

      Glad to hear that !! 🙂

Leave a Reply

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