# Send\_file problem with IE7. Save Image as untitled.bmp

**URL:** <https://www.ruby-forum.com/t/send-file-problem-with-ie7-save-image-as-untitled-bmp/148751>\
**Category:** Rails\
**Created:** [September 16, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/send-file-problem-with-ie7-save-image-as-untitled-bmp/148751 "2008-09-16T20:28:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![noelw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b4bc9f/32.png) [@noelw](https://www.ruby-forum.com/u/noelw)\
**Post date:** [September 16, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/send-file-problem-with-ie7-save-image-as-untitled-bmp/148751/1 "2008-09-16T20:28:16Z")

</div>

Platform = Linux and Mongrel

I’m using send\_file to send images from a controller. like this:

send\_file( @content.location, :disposition =\> ‘inline’, :type =\>  
File.mime\_type?(@content.location)) # mime\_type? courtesy of mimetype\_fu

This is called for in an ordinary ![]() tag.

It all works perfectly except for one minor hitch which is driving me  
mad.

If you right click on the image in IE7 and choose “Save Image As…” the  
file save dialog always defaults the filename to “untitled.bmp”.

Other browsers always get the correct file name (usually something like  
“61.png” or “18.jpg”)

If I copy the file into the corresponding path under RAILS\_ROOT/public  
then IE7 will get the filename correct - as will all browsers.

Interestingly if you do save the file as untitled.bmp it’s a perfectly  
good bmp file.

The HTTP headers set by mongrel differ substantially from the ones set  
by send\_file.

Using send\_file gives:

Status=OK - 200  
Date=Tue, 16 Sep 2008 18:16:59 GMT  
Server=Mongrel 1.1.4  
Vary=Host  
Status=200 OK  
X-Runtime=0.01416  
Content-Transfer-Encoding=binary  
Cache-Control=private  
Content-Disposition=inline; filename=“16.jpg”  
Content-Type=image/jpeg  
Content-Length=164553  
X-Cache=MISS from [www.sharehost.co.uk](http://www.sharehost.co.uk)  
Keep-Alive=timeout=15, max=100  
Connection=Keep-Alive

Serving the file from the public area gives:

Status=OK - 200  
Date=Tue, 16 Sep 2008 18:17:09 GMT  
Vary=Host  
Etag=“48cfb25c-65c2f-918190”  
Last-Modified=Tue, 16 Sep 2008 13:19:24 GMT  
Content-Type=image/jpeg  
Content-Length=416815  
X-Cache=MISS from [www.sharehost.co.uk](http://www.sharehost.co.uk)  
Keep-Alive=timeout=15, max=99  
Connection=Keep-Alive

Anybody know what I can do about this?

---

<div class="post-metadata">

**Author:** ![noelw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b4bc9f/32.png) [@noelw](https://www.ruby-forum.com/u/noelw)\
**Post date:** [September 16, 2008, 11:04pm UTC](https://www.ruby-forum.com/t/send-file-problem-with-ie7-save-image-as-untitled-bmp/148751/2 "2008-09-16T23:04:44Z")

</div>

Noel W. wrote:

> If you right click on the image in IE7 and choose “Save Image As…” the  
> file save dialog always defaults the filename to “untitled.bmp”.

Try using send\_file’s :filename option.

–  
Rails Wheels - Find Plugins, List & Sell Plugins -  
[http://railswheels.com](http://railswheels.com)

---

<div class="post-metadata">

**Author:** ![noelw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b4bc9f/32.png) [@noelw](https://www.ruby-forum.com/u/noelw)\
**Post date:** [September 16, 2008, 11:20pm UTC](https://www.ruby-forum.com/t/send-file-problem-with-ie7-save-image-as-untitled-bmp/148751/3 "2008-09-16T23:20:17Z")

</div>

Mark Reginald J. wrote:

> Noel W. wrote:
> 
> > If you right click on the image in IE7 and choose “Save Image As…” the  
> > file save dialog always defaults the filename to “untitled.bmp”.
> 
> Try using send\_file’s :filename option.
> 
> –  
> Rails Wheels - Find Plugins, List & Sell Plugins -  
> [http://railswheels.com](http://railswheels.com)

I already tried that but it makes no difference - the response headers  
are exactly the same. In fact in the one instance when explorer gets it  
right (when the file is served normally without using send\_file) there  
is no content-disposition header and no mention of the filename in any  
of the other headers either.

Thanks anyway!

---

<div class="post-metadata">

**Author:** ![noelw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b4bc9f/32.png) [@noelw](https://www.ruby-forum.com/u/noelw)\
**Post date:** [September 16, 2008, 11:34pm UTC](https://www.ruby-forum.com/t/send-file-problem-with-ie7-save-image-as-untitled-bmp/148751/4 "2008-09-16T23:34:40Z")

</div>

Your other solution that should work is to set the header directly  
that IE is parsing, Content-Disposition.

i.e.:

headers[‘Content-Disposition’] = “inline; filename="” + @filename +  
“"”

-Brady  
removed\_email\_address@domain.invalid

On Sep 16, 12:28 pm, Noel W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![noelw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b4bc9f/32.png) [@noelw](https://www.ruby-forum.com/u/noelw)\
**Post date:** [September 17, 2008, 1:51am UTC](https://www.ruby-forum.com/t/send-file-problem-with-ie7-save-image-as-untitled-bmp/148751/5 "2008-09-17T01:51:42Z")

</div>

brady8 wrote:

> Your other solution that should work is to set the header directly  
> that IE is parsing, Content-Disposition.
> 
> i.e.:
> 
> headers[‘Content-Disposition’] = “inline; filename="” + @filename +  
> “"”
> 
> -Brady  
> removed\_email\_address@domain.invalid
> 
> On Sep 16, 12:28ï¿½pm, Noel W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Thanks, but send\_file already puts the correct Content-Disposition  
header in the response, but IE only seems to work properly when it’s  
missing - but there are other differences in the headers, so I can’t  
tell if that is significant or not.

## Here is the response header that you get when the server sends a file from a public folder. It works properly with all the browsers I’ve tried

Status=OK - 200  
Date=Tue, 16 Sep 2008 18:17:09 GMT  
Vary=Host  
Etag=“48cfb25c-65c2f-918190”  
Last-Modified=Tue, 16 Sep 2008 13:19:24 GMT  
Content-Type=image/jpeg  
Content-Length=416815  
X-Cache=MISS from [www.sharehost.co.uk](http://www.sharehost.co.uk)  
Keep-Alive=timeout=15, max=99  
Connection=Keep-Alive

This is what send\_file is producing. It doesn’t work properly with IE -

Status=OK - 200  
Date=Tue, 16 Sep 2008 18:16:59 GMT  
Server=Mongrel 1.1.4  
Vary=Host  
Status=200 OK  
X-Runtime=0.01416  
Content-Transfer-Encoding=binary  
Cache-Control=private  
Content-Disposition=inline; filename=“16.jpg”  
Content-Type=image/jpeg  
Content-Length=164553  
X-Cache=MISS from [www.sharehost.co.uk](http://www.sharehost.co.uk)  
Keep-Alive=timeout=15, max=100  
Connection=Keep-Alive

I did wonder if the doubled Status header is the source of the problem -  
but I’ve no idea how to get rid of it without abandoning the use of  
send\_file.

if there was a way to get send\_file to produce a response like the  
first one I’d be quite happy.

otherwise I’ll just have to put up with it - it’s not terribly serious  
just inconsistent.

Maybe I could make the controller create a publicly accesible symlink to  
the file, do a redirect to the same controller/action and then delete  
the link again.

I’ve been frigging about with this for 3 days now. Not feeling terribly  
Agile.
