Anon
Anon

Reputation: 1

Treat PNG file as PHP

I want to upload a PHP file to a server under a PNG extension, while still being able to view it in my browser as a PHP file. How can I do that? Thanks.

Upvotes: 0

Views: 886

Answers (4)

roychri
roychri

Reputation: 2936

Use the following in your .htaccess file in the directories where your files are:

<FilesMatch "\.png$">
    SetHandler application/x-httpd-php
</FilesMAtch>

Note that ALL files with .png will be handled by PHP with this.

Upvotes: 3

Andreas
Andreas

Reputation: 5335

You can add AddType application/x-httpd-php .png to an .htaccess file (assuming your host allows you to use .htaccess files), and Apache will send those file off to be parsed by PHP.

Upvotes: 1

cotton.m
cotton.m

Reputation: 455

Why not use URL Rewriting for this?

Upvotes: 0

You cannot. PHP is server-side code and is not rendered in the browser.

Upvotes: -1

Related Questions