473,761 Members | 2,384 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

link to local files through a dynamic page

I decided to flesh out my php skills by building a web application
which could scan through local files on my intranet (specifically
mapped drives on my server) and generate a list of Movies or pictures
or music, etc. Which worked fine, I created the code to do that and to
store the results in a mysql database. I can even print it out to a
..php page and sort it however I like.

What I can't seem to do is to create links to the data I've indexed in
a way that will let me open them from the generated php page. I've
searched and searched and there just doesn't seem a way to do this.
I'm pretty sure I've exhausted the obvious options.

The following trials did not work when the document was served from an
apache web server.

<?php
echo "<h1><a href=file:///c:/temp.txt> HEY </a></h1>";
echo "<h1><a href=file:///c:\temp.txt> HEY </a></h1>";
?>
<a href=file:///c:\temp.txt target="_top"> temp.txt </a>
<a href=file:///c:/temp.txt target="_top"> temp.txt </a>

When the same page was loaded directly from the file instead of served
through apache the bottom two links worked. This doesn't really help
me however. I need to be able to dynamicly generate pages that link to
the files.

I've read that browser security is the restricting factor in this but
changing all of my security settings in IE to low didn't seem to affect
it (not sure what the equivalent of security settings is in Firefox).
Does anyone know of a way to link to local files directly in a way that
lets you open them directly from the source instead of by downloading
them to a temp file or saving the file to somewhere locally? Is it
even possible in PHP?

Any help would be much appreciated.

Matt Walker

Feb 27 '06 #1
1 2755
Matt Walker wrote:
I decided to flesh out my php skills by building a web application
which could scan through local files on my intranet (specifically
mapped drives on my server) and generate a list of Movies or pictures
or music, etc. Which worked fine, I created the code to do that and to
store the results in a mysql database. I can even print it out to a
.php page and sort it however I like.

What I can't seem to do is to create links to the data I've indexed in
a way that will let me open them from the generated php page. I've
searched and searched and there just doesn't seem a way to do this.
I'm pretty sure I've exhausted the obvious options.

The following trials did not work when the document was served from an
apache web server.

<?php
echo "<h1><a href=file:///c:/temp.txt> HEY </a></h1>";
echo "<h1><a href=file:///c:\temp.txt> HEY </a></h1>";
?>
<a href=file:///c:\temp.txt target="_top"> temp.txt </a>
<a href=file:///c:/temp.txt target="_top"> temp.txt </a>

When the same page was loaded directly from the file instead of served
through apache the bottom two links worked. This doesn't really help
me however. I need to be able to dynamicly generate pages that link to
the files.

I've read that browser security is the restricting factor in this but
changing all of my security settings in IE to low didn't seem to affect
it (not sure what the equivalent of security settings is in Firefox).
Does anyone know of a way to link to local files directly in a way that
lets you open them directly from the source instead of by downloading
them to a temp file or saving the file to somewhere locally? Is it
even possible in PHP?

Any help would be much appreciated.

Matt Walker

Hi Matt,

This has actually little to do with PHP.
PHP just delivers the code (html) for the webpage.
So you have to figure out what HTML will link right to local filesystem, and
then let PHP mimic it.

Thing you can try:
1) make your href-value valid by adding ""
so:
<a href="path/to/your/file">yourfilen ame</a>

2) add backslashes if in doubt to pathname:
<a href="G:\\foler \\filename.mp3" >file</a>

Note: On IE the following syntax always worked for me:
<a href="C:\somefo lder\somefile.m p3">filename</a>
So that is without backslashes and without file:///

Just go to the right foler with explorer (not IE), and copy the path.
If you feed the same to a hyperlink, IE will follow it AFAIK.

Firefox has disabled local browsing by default.
You can turn it on somewhere if you want.

Hope that helps.

Regards,
Erwin Moller
Feb 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
5933
by: Sean | last post by:
Hi I've written an HTML page that has a link to an MPG file, to be burned onto a "Demo CD". The MPG file is quite big - 500MB. On my computer, it works fine - clicking the link opens up Windows Media Player, which starts showing the video. But on another computer, the link opens up a new browser page, and shows the video as an embedded QuickTime video. The problem is (I think this might be QuickTime's fault) that it takes about 5...
6
3777
by: JimO | last post by:
Is there any way to reset a link's state. In other words reset a visited link to an unvisited link. I guess the question I'm asking would be how do you programatically search and clear the history of a particular page?
13
2703
by: Derek | last post by:
As I understand it there is a good amount of link compatibility among C compilers. For example, I can compile main.c with GCC and func.c with Sun One and link the objects using either linker (GNU or Sun). What I'm curious about is why this compatibility exists in the absence of a standard C ABI? What encourages C compiler vendors to agree on implementation issues such as alignment, packing, etc., such that their object
1
447
by: brian | last post by:
'visual studio 2002 pro 1.0 framwork' I am creating dynamic Link buttons on my intranet site and assigning a click_event to them. A user clicks a link and I call the method to recreate the links in the page load so the click event will be recogonized. This works! Now the link previously clicked actually will generate a new list of link buttons in the click event. Once I load
8
6143
by: MoshiachNow | last post by:
HI, I try to open a link using %windir% in path: <LI><A HREF="%windir%/temp/MainSetupLog.log">F </A></LI> The browser does not seem to find the file. However,If I paste in the Address window: file:///%windir%/temp/MainSetupLog.log
5
2156
shishisu
by: shishisu | last post by:
I figure this might be a fun challenge to some of you out there... I appreciate all the help. Thanks in advance. Here we go... I have 2 web page (on different servers) I am working on. Here, we'll call them Page-A and Page-B. I want to save some work by only having to maintain 1 web page and the changes made to source page will get reflect onto the other one. In this case, Page-A is the source and Page-B should just have a content...
38
5076
by: ted | last post by:
I have an old link that was widely distributed. I would now like to put a link on that old page that will go to a new page without displaying anything.
1
1430
by: BD | last post by:
This is probably fairly simple but I've looked at so much code an the last few days that my brain is fried. In the past I had an HTML page that contained a lot of code items and each item was contained in it's own hidden <div>. The div was displayed by extracting the bookmark, for example mypage.htm#sec2 would display the div with the id of sec2. It worked but as you can imagine it was rather clumsy as the number of items increased. At...
12
2835
by: prashant | last post by:
hi, i am trying to create an xml tag ref to hold link.php?id=1; or link.php?id=2 and so on. I want the links for all the fields(id) in the databse so that when i call them in my html page for google maps i have the whole link.The tag in the php page i am using is echo 'ref="link.php?id='.$row . '"'; the tag in html is <a href="+ref+">" +"more info"+ "</a>"
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10111
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.