Author Topic: readfile() workaround  (Read 3090 times)


  • Beginner
  • *
  • Posts: 10
    • abeMedia - Web Design Brighton
readfile() workaround
« on: July 18, 2009, 17:57:01 pm »

I installed Virtuemart 1.1.3 on one of my clients servers, however readfile() is disabled and they don't allow modifications to php.ini

Is there a workaround? I found this: but it didn't seem to work unless I was doing something wrong...

Any help would be greatly appreciated!



  • Beginner
  • *
  • Posts: 4
Re: readfile() workaround
« Reply #1 on: October 10, 2009, 15:49:23 pm »
If you get a error when calling the image directly in the browser like this:

And get this error:

<b>Warning</b>:  readfile() has been disabled for security reasons in <b>/home/yoursite/public_html/components/com_virtuemart/show_image_in_imgtag.php</b> on line <b>155</b><br />

You can ad the function to the named files in the tread named above like this (just above the first readfile call):

function rpl_readfile($file){
    echo @fread($handle,filesize($file));

and then change ALL the readfile cals in rpl_readfile like this:

if( file_exists( $fileout ) ) {
  /* We already have a resized image
  * So send the file to the browser */

         case ".gif":
            header ("Content-type: image/gif");
         case ".jpg":
            header ("Content-type: image/jpeg");
         case ".png":
            header ("Content-type: image/png");

If you do this in the other mentioned files: (for vm 1.1 don't know if there are more in 1.13)

You can solve the problems not showing tumpnail images in browse pages and a lot of javascripts erros.... on other pages....


  • Jr. Member
  • **
  • Posts: 78
    • Web design Hosting & Seo
Re: readfile() workaround
« Reply #2 on: March 25, 2010, 14:43:35 pm »
Sorry for opening this thread again but I am stuck and have tried most things in the Forum and can not get it right.

Running VM 1.1.2

The procedure you explained for the file : show_image_in_imgtag.php

Is it the same for VM 1.1.2 - please could you describe in a bit more detail what to do here to a NON CODER  ???

Managing Member of Hosting-Webdesign