how do I create a hyperlink to a local file?

I am searching all files in a folder for a specific string. When I find that string I want to create a hyper link to it so that the user can open the file. I am working in PHP and the IDE I am in does not have a hyperlink button.
LVL 1
evaultAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Infinity08Connect With a Mentor Commented:
Just use something like :

        <a href="http://yourhost.com/path/to/file.xls">Excel file</a>

making sure that the Excel file is accessible through the web server.
0
 
Infinity08Commented:
file://  and then the path to the file should do the trick ...
0
 
nizsmoDeveloperCommented:
>>...I want to create a hyper link to it so that the user can open the file...

What kind of file do you want the user to open exactly? What kind of files are you searching?

Also are you able to post some code so that we can maybe try and help you modify from there?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
nizsmoDeveloperCommented:
@Infinity08

That will work, but what if the script gets uploaded to another server? the filepaths are probably better to be relative to the script you are running I think, so that you know it will always work.
0
 
evaultAuthor Commented:
The file will always be located on the server side in a specified directory. I've got all that done. IThe user enters a string, the files in the specified folder are searched for that string and when I find the file that contains the string I want to open the file (spreadsheet) on the client side.

The idea is to open a spreadsheet with PHP through a hyperlink rather than creating some client side scripting.
0
 
Infinity08Commented:
>> The file will always be located on the server side in a specified directory.

Then it's not a local file (for the client), and file:// will not worked, unless you have direct access to the drive that contains the files.

You could make the files available through the web server using http:// addresses.
0
 
eXman_plCommented:
If I got this right you should use a file iterator which will open any file, search for the string, and if the string is in that file get the name of that file and write it as a hyper link on the page.
0
 
evaultAuthor Commented:
One of the problems I am facing is that I am trying to open an Excel file; not an easy task with PHP. That's why I want to use some kind of hyper link and let the client PC open it automatically, just like when you are browsing the web and you click on a link pointing to a file and it pops up with a dialog that says open or save.
0
 
evaultAuthor Commented:
I know how to create the link. What I am trying to do is put it inside a label or text box so that it will be in the same place after every search.
0
 
eXman_plCommented:
So you just do smthing like this

<input type="text" value="<?php echo $_link_value" ?>" />
or

<label><?php echo $_link_value" ?></label>
0
 
Infinity08Commented:
>> What I am trying to do is put it inside a label or text box so that it will be in the same place after every search.

I'm afraid you've lost me there ... what are you trying to put in which same place ? Are you going to move the file ? If not, the link should still be valid.
0
 
evaultAuthor Commented:
here is the solution I came up with ->
                 $link1 = "?><body bgcolor=".Chr(34)."white".Chr(34)." text=".Chr(34)."black".Chr(34).
                  " link=".Chr(34)."blue".Chr(34)." vlink=".Chr(34)."purple".Chr(34)." alink=".Chr(34).
                  "red".Chr(34)."><p><a href=";
                 $link2 = Chr(34)."javascript:na_open_window(".Chr(39)."win".Chr(39).", ";
                 $link3 = Chr(39).$PathFile.Chr(39);
                 $link4 = ", 5, 5, 900, 600, 0, 0, 0, 0, 1);".Chr(34)." target=".Chr(34);
                 $link5 = "_self".Chr(34).">".$file."</a></p></body><?php";
                 $linky = $link1.$link2.$link3.$link4.$link5;
                 $this->Label4->Caption = $linky;
0
All Courses

From novice to tech pro — start learning today.