# File links in browser

**URL:** <https://www.ruby-forum.com/t/file-links-in-browser/189411>\
**Category:** Rails\
**Created:** [May 31, 2010, 3:07pm UTC](https://www.ruby-forum.com/t/file-links-in-browser/189411 "2010-05-31T15:07:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [May 31, 2010, 3:07pm UTC](https://www.ruby-forum.com/t/file-links-in-browser/189411/1 "2010-05-31T15:07:14Z")

</div>

Basically, if i open an txt file in firefox using “File \> Open file”  
then file is opening perfectly. But if i try to open a txt file from a  
file link on a webpage “file:///path” it is not going anywhere?

Can i fix that in ROR ? If i can, then what is the way to get rid of  
this ?

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [May 31, 2010, 3:30pm UTC](https://www.ruby-forum.com/t/file-links-in-browser/189411/2 "2010-05-31T15:30:53Z")

</div>

On Mon, May 31, 2010 at 6:07 AM, Hemant B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Basically, if i open an txt file in firefox using “File \> Open file”  
> then file is opening perfectly. But if i try to open a txt file from a  
> file link on a webpage “file:///path” it is not going anywhere?

? What _exactly_ do you mean by “not going anywhere”?

Does the file url exactly match a path and file on your system?

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [May 31, 2010, 4:16pm UTC](https://www.ruby-forum.com/t/file-links-in-browser/189411/3 "2010-05-31T16:16:27Z")

</div>

Hassan S. wrote:

> On Mon, May 31, 2010 at 6:07 AM, Hemant B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > Basically, if i open an txt file in firefox using “File \> Open file”  
> > then file is opening perfectly. But if i try to open a txt file from a  
> > file link on a webpage “file:///path” it is not going anywhere?
> 
> ? What _exactly_ do you mean by “not going anywhere”?

By this i mean that page is neither reloading nor going to a new tab.  
Usually if you click on a link something happens from these two. But now  
its not.

> Does the file url exactly match a path and file on your system?

Yeah path is exactly the same.

> –  
> Hassan S. ------------------------ removed\_email\_address@domain.invalid  
> twitter: @hassan

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [May 31, 2010, 4:28pm UTC](https://www.ruby-forum.com/t/file-links-in-browser/189411/4 "2010-05-31T16:28:50Z")

</div>

I’m lost. What does this have to do with rails? Sounds like a browser  
problem. :-/

Larry

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [May 31, 2010, 5:39pm UTC](https://www.ruby-forum.com/t/file-links-in-browser/189411/5 "2010-05-31T17:39:41Z")

</div>

On Mon, May 31, 2010 at 7:16 AM, Hemant B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > > Basically, if i open an txt file in firefox using “File \> Open file”  
> > > then file is opening perfectly. But if i try to open a txt file from a  
> > > file link on a webpage “file:///path” it is not going anywhere?

> By this i mean that page is neither reloading nor going to a new tab.  
> Usually if you click on a link something happens from these two. But now  
> its not.

Dunno if it’s a bug or a feature, but yeah, file URLs don’t seem to work  
in FF (or Safari, for that matter). But if the link is hand-crafted  
(which is  
what I tried), I don’t see how it could be related to Rails, in any  
case.

## FWIW,

Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [May 31, 2010, 7:02pm UTC](https://www.ruby-forum.com/t/file-links-in-browser/189411/6 "2010-05-31T19:02:32Z")

</div>

Hassan S. wrote:

> On Mon, May 31, 2010 at 7:16 AM, Hemant B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > > > Basically, if i open an txt file in firefox using “File \> Open file”  
> > > > then file is opening perfectly. But if i try to open a txt file from a  
> > > > file link on a webpage “file:///path” it is not going anywhere?
> 
> > By this i mean that page is neither reloading nor going to a new tab.  
> > Usually if you click on a link something happens from these two. But now  
> > its not.
> 
> Dunno if it’s a bug or a feature, but yeah, file URLs don’t seem to work  
> in FF (or Safari, for that matter). But if the link is hand-crafted  
> (which is  
> what I tried), I don’t see how it could be related to Rails, in any  
> case.

I have a dim memory that this is a feature, designed to prevent remote  
websites from tricking you into editing local files or reading them with  
JavaScript. But I could be wrong.

> ## FWIW,
> 
> Hassan S. ------------------------ removed\_email\_address@domain.invalid  
> twitter: @hassan

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [June 1, 2010, 10:50am UTC](https://www.ruby-forum.com/t/file-links-in-browser/189411/7 "2010-06-01T10:50:32Z")

</div>

Marnen Laibow-Koser wrote:

> Hassan S. wrote:
> 
> > On Mon, May 31, 2010 at 7:16 AM, Hemant B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > wrote:
> > 
> > > > > Basically, if i open an txt file in firefox using “File \> Open file”  
> > > > > then file is opening perfectly. But if i try to open a txt file from a  
> > > > > file link on a webpage “file:///path” it is not going anywhere?
> > 
> > > By this i mean that page is neither reloading nor going to a new tab.  
> > > Usually if you click on a link something happens from these two. But now  
> > > its not.
> > 
> > Dunno if it’s a bug or a feature, but yeah, file URLs don’t seem to work  
> > in FF (or Safari, for that matter). But if the link is hand-crafted  
> > (which is  
> > what I tried), I don’t see how it could be related to Rails, in any  
> > case.

If this is not a feature then how come file opens when a open it with  
File \> Open file. I think there must be some way in rails as well to  
open it. I’ll be back to you guys after a bit of R & D… 🙂

> > ## FWIW,
> > 
> > Hassan S. ------------------------ removed\_email\_address@domain.invalid  
> > twitter: @hassan
> 
> ## Best,
> 
> Marnen Laibow-Koser  
> [http://www.marnen.org](http://www.marnen.org)  
> removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![hemantborole](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b782af/32.png) [@hemantborole](https://www.ruby-forum.com/u/hemantborole)\
**Post date:** [June 1, 2010, 11:31am UTC](https://www.ruby-forum.com/t/file-links-in-browser/189411/8 "2010-06-01T11:31:26Z")

</div>

On May 31, 6:02 pm, Marnen Laibow-Koser [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hassan S. wrote:

> I have a dim memory that this is a feature, designed to prevent remote  
> websites from tricking you into editing local files or reading them with  
> JavaScript. But I could be wrong.

sounds like [Links to local pages do not work - MozillaZine Knowledge Base](http://kb.mozillazine.org/Links_to_local_pages_do_not_work)

Fred
