1

I want to execute only one or two jpg files like php in a folder.

forexample www/folder/index.jpg should run and shown like www/folder/index.php or www/folder/index.php should run and shown like www/folder/index.jpg but it should work as php and it should shown as jpg

and other jpg files should run it is own name www/folder/photo.jpg > www/folder/photo.jpg

htaccess
  • 105
  • 1
  • 8
  • What are you hoping to do within `index.php`? – DACrosby Jul 01 '13 at 07:08
  • I think you need to reword your question. You can't execute a JPG file - it's an image, not a program. I can't work out from your question what it is you're trying to achieve. –  Jul 01 '13 at 07:08
  • Is it stand in good stead? http://stackoverflow.com/questions/17399049/how-to-execute-jpg-or-other-extensions-like-php – Andrew Jul 01 '13 at 07:09
  • http://stackoverflow.com/questions/8025236/is-it-possible-to-execute-php-with-extension-file-php-jpg#answer-8025252 – bitWorking Jul 01 '13 at 07:11
  • Image or other programs. I wanna execute them like php. – htaccess Jul 01 '13 at 07:11

1 Answers1

0

You can't execute JPEG files per se, but you can have them be a PHP script that generates JPEG data to use in e.g. a <img> tag.

You need to set the handler for the file to application/x-httpd-php, output a content type of image/jpeg in the script, and, most importantly, output JPEG data. Might want to consider naming it <something>.jpg.php so you don't have to do the first one though, since that's server configuration.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358