Download PHP file instead of executing - WAMP Server

I am using a WAMP server to run my PHP scripts. I created a test folder in the WWW folder and tried to execute a PHP script using an HTML form action. But instead of executing, its loading a PHP file. What could be the reason?

Apache 2.4.9 PHP 5.5.12

<!DOCTYPE html> <html> <body> <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> </body> </html> 

PHP script (uploader.php)

 <?php phpinfo(); ?> 
+5
source share
4 answers

Can you send your httpd.conf here? You can also try adding the following code to your httpd.conf file and restarting WAMP

 AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php AddType application/x-httpd-php .php3 AddHandler application/x-httpd-php .php .phtml AddHandler x-httpd-php .php .phtml 
0
source

In my case, the problem was caused by the fact that the .htaccess file contained this directive for running php 7 in the Joomla directory (the old server allowed using different versions of PHP in different directories):

Application AddType / x-httpd-ea-php70.php.php7.phtml

I just comment on them on the new server and it worked. I hope this can be helpful to someone. Hey. :)

0
source

One of the reasons may be to disable "file_uploads" in your php.ini . So go to your php.ini file and check if you have file_uploads = On

-1
source

In my case, I have to delete the .htaccess file so that it works.

enter image description here

-1
source

Source: https://habr.com/ru/post/1247148/


All Articles