# Filename

**URL:** <https://www.ruby-forum.com/t/filename/142688>\
**Category:** Rails\
**Created:** [July 10, 2008, 12:10pm UTC](https://www.ruby-forum.com/t/filename/142688 "2008-07-10T12:10:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![prionko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5f9b8f/32.png) [@prionko](https://www.ruby-forum.com/u/prionko)\
**Post date:** [July 10, 2008, 12:10pm UTC](https://www.ruby-forum.com/t/filename/142688/1 "2008-07-10T12:10:41Z")

</div>

Hi,

I am using attachment\_fu plugin for uploading files. Can anybody tell me  
how to access the filename in the Model before the file gets uploaded ?  
Actually I want to a system where the users will be able to upload files  
if the filenames matches with the existing filenames already stored in a  
different table. Can anybody advice me on how to solve this problem ?

Thanks  
Saurav

---

<div class="post-metadata">

**Author:** ![prionko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5f9b8f/32.png) [@prionko](https://www.ruby-forum.com/u/prionko)\
**Post date:** [July 10, 2008, 1:33pm UTC](https://www.ruby-forum.com/t/filename/142688/2 "2008-07-10T13:33:01Z")

</div>

as far as i understand, using attachment\_fu, you cannot get the  
filename in the Model BEFORE the file gets uploaded.

One solution to you problem could be :

i. Make the use enter the filename (or path) in a textfield.  
ii. Make an ajax call to the server with the filename, to verify  
whether it exists in the database.  
iii. Enable the upload button / display error message depending on the  
result of the ajax call.

On Jul 10, 3:10 pm, Saurav C. \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![prionko](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5f9b8f/32.png) [@prionko](https://www.ruby-forum.com/u/prionko)\
**Post date:** [July 11, 2008, 6:27am UTC](https://www.ruby-forum.com/t/filename/142688/3 "2008-07-11T06:27:04Z")

</div>

Thanx for the solution.BTW is there any other plugin which will allow me  
to capture the filename before it gets uploaded in the database ??

Saurav

Unnikrishnan Kp wrote:

> as far as i understand, using attachment\_fu, you cannot get the  
> filename in the Model BEFORE the file gets uploaded.
> 
> One solution to you problem could be :
> 
> i. Make the use enter the filename (or path) in a textfield.  
> ii. Make an ajax call to the server with the filename, to verify  
> whether it exists in the database.  
> iii. Enable the upload button / display error message depending on the  
> result of the ajax call.
> 
> On Jul 10, 3:10 pm, Saurav C. \<rails-mailing-l…@andreas-
