Hi when i run php file on local host it directly go to download folder it not come in run condition
Please help me
i am new in php
thank

Dani AI

Generated

The browser downloading a .php file almost always means the file is not being executed by PHP on a web server (or the server is deliberately sending it as an attachment). ’s symptom matches that. Building on the hints from , and , the fastest way to find the root cause is a couple of small tests that show whether PHP is being parsed and what headers the server sends.

Create two tiny files in the server document root and open them through your local server address (do not open the file with the file:// file manager view):

<?php
phpinfo();
?>
<?php
echo 'hello';
?>

If the phpinfo output appears, PHP is working. If the browser downloads the file or you see PHP source in the page, PHP is not being executed.

Inspect the HTTP headers the server sends. From a terminal:

curl -I http://127.0.0.1/path/to/test.php

You want a Content-Type like text/html and no Content-Disposition: attachment. If the response shows application/octet-stream or a Content-Disposition instructing attachment, the server is treating the file as binary (or a handler is missing/misconfigured).

Common fixes and checks: confirm your PHP runtime is actually installed and enabled for the web server (module or FastCGI), ensure files really end with .php (not .php.txt), review .htaccess or server config for errant AddType/AddHandler or Content-Disposition lines, and check the web server error log for PHP/handler load failures. If you’re using a hosting-panel “preview” (as mentioned), that preview mode can force downloads — test via the real served URL. Remove any phpinfo file after testing since it exposes server details.

Recommended Answers

All 3 Replies

Member Avatar for Member #120589

Is Apache running? You need to start Apache otherwise, you may get this issue. Or if you run php files from outside the htdocs folder maybe

I think so syed is checking the file in any host provided space.There on click on any file,it will be downloaded.There is one more option called preview(as i can remember),on click of that you can see the page.
Just try to first work on local system then go to your host provided space.

make sure that the url is http://localhost/... and not file:///C:/xampp/htdocs/...
You get the wrong url if you right-clik ->open in brouwer on the file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.