Solved

how do I create a hyperlink to a local file?

Posted on 2007-11-29
12
1,352 Views
Last Modified: 2012-08-14
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.
0
Comment
Question by:evault
  • 4
  • 4
  • 2
  • +1
12 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 20372081
file://  and then the path to the file should do the trick ...
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20372082
>>...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
 
LVL 21

Expert Comment

by:nizsmo
ID: 20372086
@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
 
LVL 1

Author Comment

by:evault
ID: 20372323
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
 
LVL 53

Expert Comment

by:Infinity08
ID: 20372347
>> 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
 
LVL 1

Expert Comment

by:eXman_pl
ID: 20372348
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Author Comment

by:evault
ID: 20374309
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
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 20376169
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
 
LVL 1

Author Comment

by:evault
ID: 20378657
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
 
LVL 1

Expert Comment

by:eXman_pl
ID: 20380599
So you just do smthing like this

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

<label><?php echo $_link_value" ?></label>
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 20383292
>> 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
 
LVL 1

Author Comment

by:evault
ID: 20387480
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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses four methods for overlaying images in a container on a web page
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now