hi guys,
I have to create a download link.As a newbie in ruby i googled for it
and
found the way for my problem.
def attachment
send_file(’/images/header.gif’,
:filename => ‘My Filename!’,
:type => ‘image/gif’,
:disposition => ‘attachment’,
:streaming => ‘true’,
:buffer_size => ‘4096’)
end
but it show file download error: Cannot read file /images/header.gif
My file location /images/header.gif
what is the wrong?
please mention a better way if any.
please help me.
Amin
Ruhul A. wrote:
hi guys,
I have to create a download link.As a newbie in ruby i googled for it
and
found the way for my problem.
def attachment
send_file(’/images/header.gif’,
:filename => ‘My Filename!’,
:type => ‘image/gif’,
:disposition => ‘attachment’,
:streaming => ‘true’,
:buffer_size => ‘4096’)
end
but it show file download error: Cannot read file /images/header.gif
My file location /images/header.gif
what is the wrong?
please mention a better way if any.
please help me.
Amin
send_file takes the full path to a file that is local on the webserver,
not a url. It reads the data in that file and sends it back out to the
browser. So what you most likely need is:
send_file("#{RAILS_ROOT}/public/images/header.gif", …)
Alex W. wrote:
send_file takes the full path to a file that is local on the webserver,
not a url. It reads the data in that file and sends it back out to the
browser. So what you most likely need is:
send_file("#{RAILS_ROOT}/public/images/header.gif", …)
Thx fï½ï½’ ur helï½.
Hi,
do you know anyway to read a file with url?
Thank you
Luigi
Luigi wrote:
Hi,
do you know anyway to read a file with url?
Thank you
Luigi
Dear Luigi,
Use a library. Net::HTTP (in ‘net/http’) for http://… , Net::FTP (in
‘net/ftp’) for ftp://…, etc
You have examples in the documentation of these libraries.
If not solved… please write agin.
Tuhin