evault
asked on
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.
file:// and then the path to the file should do the trick ...
>>...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?
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?
@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.
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.
ASKER
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.
The idea is to open a spreadsheet with PHP through a hyperlink rather than creating some client side scripting.
>> 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.
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.
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.
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
So you just do smthing like this
<input type="text" value="<?php echo $_link_value" ?>" />
or
<label><?php echo $_link_value" ?></label>
<input type="text" value="<?php echo $_link_value" ?>" />
or
<label><?php echo $_link_value" ?></label>
>> 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.
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.
ASKER
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".C hr(34)." alink=".Chr(34).
"red".Chr(34)."><p><a href=";
$link2 = Chr(34)."javascript:na_ope n_window(" .Chr(39)." win".Chr(3 9).", ";
$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><?ph p";
$linky = $link1.$link2.$link3.$link 4.$link5;
$this->Label4->Caption = $linky;
$link1 = "?><body bgcolor=".Chr(34)."white".
" link=".Chr(34)."blue".Chr(
"red".Chr(34)."><p><a href=";
$link2 = Chr(34)."javascript:na_ope
$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.
$linky = $link1.$link2.$link3.$link
$this->Label4->Caption = $linky;