# Non editable file\_field

**URL:** <https://www.ruby-forum.com/t/non-editable-file-field/140884>\
**Category:** Rails\
**Created:** [June 19, 2008, 2:24pm UTC](https://www.ruby-forum.com/t/non-editable-file-field/140884 "2008-06-19T14:24:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sonu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de0a6/32.png) [@sonu](https://www.ruby-forum.com/u/sonu)\
**Post date:** [June 19, 2008, 2:24pm UTC](https://www.ruby-forum.com/t/non-editable-file-field/140884/1 "2008-06-19T14:24:02Z")

</div>

Hi,  
I need to upload files in my application  
I am using following code

Upload Document: \<%= form.file\_field("filename") %\>

But I want that the file field that gets displayed in my browser should  
not be editable.  
i.e user should be able to select the file through the browse click  
only.

---

<div class="post-metadata">

**Author:** ![sonu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de0a6/32.png) [@sonu](https://www.ruby-forum.com/u/sonu)\
**Post date:** [June 19, 2008, 2:54pm UTC](https://www.ruby-forum.com/t/non-editable-file-field/140884/2 "2008-06-19T14:54:45Z")

</div>

On 19 Jun 2008, at 14:24, Sneha G. wrote:

> should  
> not be editable.  
> i.e user should be able to select the file through the browse click  
> only.

The file field is implemented browser specifically, on Safari for  
example, there simply isn’t an editfield you can fill in. You can’t  
change this behavior. The only way it might possibly work is if you  
place a

 input field and make sure the clicks don’t fall through  
(either using onclick=“return false;” on the div or using unobtrusive  
javascript to do so). That said, make sure you check and adjust the  
placement of the 
 in all browsers and don’t show it on Safari.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![sonu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/9de0a6/32.png) [@sonu](https://www.ruby-forum.com/u/sonu)\
**Post date:** [June 19, 2008, 3:50pm UTC](https://www.ruby-forum.com/t/non-editable-file-field/140884/3 "2008-06-19T15:50:34Z")

</div>

Peter De Berdt wrote:

> On 19 Jun 2008, at 14:24, Sneha G. wrote:
> 
> > should  
> > not be editable.  
> > i.e user should be able to select the file through the browse click  
> > only.
> 
> The file field is implemented browser specifically, on Safari for  
> example, there simply isn’t an editfield you can fill in. You can’t  
> change this behavior. The only way it might possibly work is if you  
> place a
> 
> input field and make sure the clicks don’t fall through  
> (either using onclick=“return false;” on the div or using unobtrusive  
> javascript to do so). That said, make sure you check and adjust the  
> placement of the 
> in all browsers and don’t show it on Safari.
> 
> Best regards
> 
> Peter De Berdt
> 
> But atleast is it possible to handle  
> i.e if the user is editing the wrong path  
> an error message should get flashed  
> But in my case whwtever path you mention it is getting saved.
