Web Analytics Made Easy -
StatCounter html link for local file not working in php file - CodingForum

Announcement

Collapse
No announcement yet.

html link for local file not working in php file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • html link for local file not working in php file

    I have a question , I tried a simple example for html link inside php file
    I have a file called file1.txt inside C:\

    I put the following lines in a file and named it .html

    <html>
    <a href='C:\file1.txt'> open file</a>
    </html>

    here the link works and the file opens upon clicking

    if the same file I named it .php and tried to run it using apache localhost
    here when you click the link, nothing happen and the file didn't open

    why??

    knowing that if we put any website link it works , but if we put any file inside our computer it doesn't work.

  • #2
    are you sure you have php installed? Put
    PHP Code:
    <?php phpinfo(); ?>
    on your page.

    Comment


    • #3
      I'm sure, I'm working on a large project with php, and i said before that the file is running but when clicking on the link the file is not openning

      Comment


      • #4
        When you click on a link that has a target url with a .txt extension, the web server simply servers up that file. The server reads the file and outputs the contents to the browser.

        When you click on a link that has a target url with a .php extension, the file will be parsed by the PHP language interpreter and you will only get any output from echo/print/print_r statements that are contained in the PHP code within the file. This is the reason why things like user names/passwords that are assigned to constants/variables are safe when they are inside of .php files.

        Browsing to a .php file with the following, will not result in anything being sent to the browser -
        PHP Code:
        <?php
        $password 
        'mysecret';
        ?>
        Finding out HOW to do something is called research, i.e. keep searching until you find the answer. After you attempt to do something and cannot solve a problem with it yourself, would be when you ask others for help.

        Comment


        • #5
          sorry, but you went so far away from my question
          if u read my question carefully u'll know what is the problem
          the name of the file inside url is not the problem, the name of the whole file that contain the code is the problem
          anyways, thank u for your care
          Last edited by manamino; Oct 16, 2006, 04:20 PM.

          Comment


          • #6
            if you're running with a web-server, don't use file-based urls.

            (and your initial post was hardly clear, so perhaps try and clarify if people are clearly confused...)
            My thoughts on some things: http://codemeetsmusic.com
            And my scrapbook of cool things: http://gjones.tumblr.com

            Comment

            Working...
            X