1. Welcome to CinVin!
    CinVin is a friendly general discussion community. From TV shows to graphics to technology to games and everything in between, this is the place to talk about it!

Have .PNG File Run As .PHP File

Discussion in 'Technology' started by Kevin, Aug 14, 2011.

  1. Kevin Code Monkey

    Message Count:
    537
    Likes Received:
    96
    Trophy Points:
    48
    For a XenForo project I am working on, that dynamically generates a png image, I needed to have a specified png file (shown using a standard img tag) to behind-the-scenes point instead to a php file to execute the code.

    At least with an Apache server the solution is quite simple. (y)

    In the folder where your php file resides, create an .htaccess file, or modify it if you already have, and add this entry. Just update the "file.png" value to the be the name of the png image that you will be showing to the user and the "file.php" value to the actual name of the script that you want to run.
    Code:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^file.png$  file.php [L]
    </IfModule>
    This method is generic so you can do this for just about any file that you wish to swap instead of just a png & php file. You're just doing a command to tell Apache that "If somebody requests file X then serve file Y instead." during the page load.

Share This Page

Pin It

Users found this page by searching for:

  1. run png as php

    ,
  2. run php from png

    ,
  3. how to run png file

    ,
  4. execute code php in png file,
  5. create png file from php,
  6. execute php from png image file,
  7. execute png file in php,
  8. image png execute code php,
  9. execute .php.png,
  10. как запустить php из png,
  11. how to run a png file,
  12. execute png as php,
  13. execute php code from png,
  14. запуск php.png файла,
  15. <ifmodule mod_rewrite.c> filerun