File upload

is there any link for step by step guide in file upload in database …
im follwing the link
Ruby on Rails - File Uploading | Tutorialspoint
which shows file upload into folder not in database …pls help…

Jai Jai wrote:

is there any link for step by step guide in file upload in database …
im follwing the link
Ruby on Rails - File Uploading
which shows file upload into folder not in database …pls help…

Hi

its never advisible to put the image into the db only the path of that
image will be stored in the db…if you store the whole image into the db
then the db size will be very large…and its not the best thing to
do…So store only the path and not the image…

Thanks

Dhaval P.
Software Engineer
Ruby on Rails

friend …i need to upload file path or file name into database …

my upload.rhtml is

New File

<% form_for :upload, @upload, :url => { :action => 'new' }, :html => { :multipart => true } do |f| %>

Bestand:
<%= f.file_field :upload %>

<%= submit_tag 'Upload' %> <% end %>

in my controller i ve used

def new
if request.post?
@upload = Upload.new(params[:upload]).save

end

end
but its not working any help pls…& i also need to upload it in folder
too.

is there any link to guide file upload

Jai Jai wrote:

is there any link to guide file upload

Let me Explain You How To Upload File into Database :

In This Case we have table called “boxes” for saving your file and Model
name Boxe

Column Names ==>> file_name | file_data | file_content
Type Data ==>> string | blod | string


CONTROLLER

def save_file

if params[:upload] != nil
if params[:upload][‘file’].size > 1
@warez = Box.new(params[:upload])
@warez.file_name = params[:upload][‘file’].original_filename
@warez.file_data = params[:upload][‘file’].read
@warez.file_content = params[:upload][‘file’].content_type.chomp
@warez.save
end
end

end

def download_file
@download_warez = Box.find(params[:id])
send_data(@download_warez.file_data,
:filename => @download_warez.file_name,
:type => @download_warez.file_type)
end


VIEW

<% form_tag ({:action => “save_file”}, {:multipart => true}) do %>
<%= file_field “upload”, “file” %>
<%= submit_tag “Upload” %>
<% end %>
<%= end_form_tag %>

g00d Lvck
Reinhart
http://teapoci.blogspot.com

thank you very much friend…it works charm…

Correction at :

def download_file

:type => @download_warez.file_type)

The correct is :
:type => @download_warez.file_content)

and the model name not Boxe but Box.

Reinhart

use atachement_fu or file_column plugin it handles everything
magically.
Check there documentation , google is god remember.!!

CJ(JON)

hi Dhaval,

i have the same problem what you had.the problem is

is there any link for step by step guide in file upload in database …
im follwing the link
Ruby on Rails - File Uploading
which shows file upload into folder not in database …pls help…

did u get the solution.
if u get it please let me know wht is the solution.
its very urgent for me.

Dhaval P. wrote:

Jai Jai wrote:

is there any link for step by step guide in file upload in database …
im follwing the link
Ruby on Rails - File Uploading
which shows file upload into folder not in database …pls help…

Hi

its never advisible to put the image into the db only the path of that
image will be stored in the db…if you store the whole image into the db
then the db size will be very large…and its not the best thing to
do…So store only the path and not the image…

Thanks

Dhaval P.
Software Engineer
Ruby on Rails
http://www.railshouse.com

Jai zenag wrote:

is there any link for step by step guide in file upload in database …
im follwing the link
Ruby on Rails - File Uploading
which shows file upload into folder not in database …pls help…

hi jai,
iam also facing the same problem wht you had faced.
did u get the solution for that problem,if u get it please let me know
what is the solution. please its very urgent.