views:

76

answers:

4

We are developing a functionality that allows the users to save the downloaded file. We are struggling to get a popup where the user can select a target location / folder to save his file. Can this be achieved using rails?

A: 

I think it depends on the content-type and similar headers you're returning to the user. Try returning something like:

header('Content-disposition: attachment; filename=movie.mpg');
header('Content-type: video/mpeg');

EDIT: I am assuming you're able to generate headers and returning a file to the user by HTTP (no simple links to files)

rossoft
A: 

I think you are trying to give something like file browser dialog box which allows client to save file on a particular location.

In case you are trying to give this from your server then I should say it is not possible due to security restriction which browser makers have applied to ensure client's security.

Another way is to let client download your browser plugin/activeX Control which basically is control over client's machine then you can do what you want i.e. something like this also.

I think without this the filetype downloaded by client is identified (based on headers) by browser and it opens the file save dialog box automatically and you cant enter into client's secure arena.

Beginner
How do I allow client to download browser plugin/activeX control? Can you suggest the way to do it?
Aditya
When we make ActiveXControl and then use it in website as JavaScript object. This JavaScript object can call functions written in ActiveXControl like xmlhttprequest plugin has send() method in its plugin.When Client Browses it asks to download that plugin. In case you allow then browser downloads it and install it for you. Similarly your plugin will be installed, but plugins are mostly not recommended as most users hesitate to download that untill and unless it is something from sites which user trust.
Beginner
+1  A: 

I think you're looking for send_file - it's very easy to use.

Andy Gaskell
A: 

I think you want download file option. For example on hitting a URL you want user to download a zip file code for it you can do something like this:

class MyController < ApplicationController
  def downloadzip
     send_file "path_to_file", :type=>"application/zip"
   end
end
prasadvk