# Error in send\_file

**URL:** <https://www.ruby-forum.com/t/error-in-send-file/123366>\
**Category:** Rails\
**Created:** [December 17, 2007, 4:24am UTC](https://www.ruby-forum.com/t/error-in-send-file/123366 "2007-12-17T04:24:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [December 17, 2007, 4:24am UTC](https://www.ruby-forum.com/t/error-in-send-file/123366/1 "2007-12-17T04:24:38Z")

</div>

I’m trying to add a link to download a zip file. I created a  
controller method that makes the call to send\_file:

def getzip  
send\_file ‘file.zip’  
end

When I navigate to this link I get a MissingFile exception. The file  
definitely exists (and U triple-checked paths and spelling) and the  
permissions are 644. I tried moving it to the /public folder and  
updating the getzip method to grab it from here, but I still get the  
same exception. Is there any configuration with rails or apache I can  
check? I have used send\_data in other modules without any problems,  
so I’m scratching my head on this one.

Thanks.

Mike

---

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [December 17, 2007, 5:09am UTC](https://www.ruby-forum.com/t/error-in-send-file/123366/2 "2007-12-17T05:09:07Z")

</div>

On 17 Dec 2007, at 03:24, Mike wrote:

> I’m trying to add a link to download a zip file. I created a  
> controller method that makes the call to send\_file:
> 
> def getzip  
> send\_file ‘file.zip’  
> end

A path like that will be relative to your current working directory  
(usually the same as you rails\_root). Try using an absolute path/not  
relying on the current working directory (ie /foo/bar/file.zip or  
RAILS\_ROOT + ‘/file/zip’.  
File.expand\_path ‘file.zip’ should tell you exactly what path it’s  
trying to access.

Fred

---

<div class="post-metadata">

**Author:** ![mike](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike](https://www.ruby-forum.com/u/mike)\
**Post date:** [December 18, 2007, 1:00am UTC](https://www.ruby-forum.com/t/error-in-send-file/123366/3 "2007-12-18T01:00:56Z")

</div>

Thanks! Using expand\_path ‘file.zip’ showed it was looking for it in /  
public. I suspected it was looking there, but I was using ‘/public/  
code.zip’ instead of just the filename.

Mike

On Dec 16, 11:08 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
