How to Fix readfile Problem on TimThumb


Sponsored Links




TimThumb is my favorite Auto Generated Thumbnail code ever seen, simple to use and work great in almost server. But there are readfile function problem on some server in TimThumb auto resized imaged on the fly, this script development by Darren Hoyt and Tweak by Ben Gillbanks, The problem that I currently have is readfile function that disabled by Hosting Server Administrator, they said disabled this function for security reason. So I googling to find out how to fix this problem.

After we googling with several keyword, I got the best solutions from OJAK AJA, and here what we must do. Open your TimThumb script and find this code (around line 496 on version 1.12)

readfile( $cache_file );

Then you need replace readfile function with file_get_contents, Sigiro said, this is the best method, beside file_gets_contents, there are several PHP Functions we can use, such as fpassthru, back to this tricks, to make your TimThumb work, replace code above with this code

$img_data = file_get_contents( $cache_file );
 echo $img_data;

And done, this tricks work like charms in my server client. I hope tricks to fix Readfile Problem on TimThumb is worked on you too

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net


16 Responses to How to Fix readfile Problem on TimThumb

  1. Pingback: Very Useful 65 Wordpress Hacks | Design your way

  2. Pingback: How To Display Twitter counter in Text # WordPress Tricks & Tips

  3. Pingback: How To Integrate Images Shortcode with TimTumb # WordPress Tricks & Tips

  4. Jonathan says:

    Maybe it was a CHMOD permissions issue. cache / temp and timthumb.php needed to be 755 instead of 777.

    http://www.jeffkee.com/timthumb-php-404-apache-php-security-chmod-755-777-error-lo/

  5. François says:

    My TimThumb.php file stop (suddenly) to work this morning with this error “PHP Warning: readfile() has been disabled for security reasons in /path/to/timthumb.php on line 484″

    But with your trick everything is back to life now !

    Thanks.

  6. jehzlau says:

    still didn’t work for me.. huhuhu.. I don’t know what to do now. wah!

  7. wilbur says:

    I use Headway theme and wordpress 3.01.1 and i cant see the small images i get 404 406 errors

  8. Pingback: Wordpress hacks and tricks | Wordpress Theme Designing, Blog Optimization, Wordpress Videos

  9. trismile says:

    Thanks,

    This advice solved my problem . :)

  10. Qasim Yad says:

    well done!!!
    you rock bro. i have solve my problem.
    may you get satisfied life ………….

  11. Ansen says:

    Hello Wp Tricks,
    I got problem with my shared hosting hostgator, they ask me to solve the timthumb on my freshlife theme, my blog visitor getting 30000/day so the hosting ask me to solve that because my blog consumption too many resource make the server down, they said.
    Bellow the twarning from my server:

    After reviewing the documentation in the opening reply, the issue appears to be centered around your theme. Specifically the timthumb feature which may be dynamically resizing your images. Dynamically resizing images not only puts load on the server, but it also slows down the load times for the site itself. In order to resolve this issue I highly recommend updating your wordpress to use a less resource intensive theme while you address freshlife

    A common solution would be to resize images before uploading them to your blog. Or contact the theme creator for any caching or optimizations which may be available for the theme.

    Please reply with the ip address shown at the url: http://www.hostgator.com/ip.shtml and include any further modifications which may have been made.

    If you have any questions or concerns, please don’t hesitate to contact us. We are more than happy to assist you.

    Thank you for helping me !

  12. Pingback: Very Useful 65 Wordpress Hacks | Stevelizardi.com

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>