kenapa nggak pake plugin attachment_fu atau paperclip aja mas?
tapi kalo masih pengen pake blob caranya masih sama,
tinggal ditambahkan field file type saja CMIIW
contohnya ini pake blob kan ya?


ZEN FTSM wrote:
>
> Salam..
>
> Untuk mengupload/menyimpan file image/foto ke mysql saya menggunakan 
> sintak..:
>
> Controller:
>
> def create
> @pelajar = Pelajar.new(params[:pelajar])
> respond_to do |format|
> pelajar.save
> format.html { redirect_to(@pelajar) }
> end
>
> def code_image
> @image_data = Pelajar.find(params[:id])
> @image = @image_data.binary_data
> send_data(@image, :type => @image_data.content_type, :namafail => 
> @image_data.namafail, :disposition => 'inline')
> end
>
> Model:
>
> def image_file=(input_data)
> self.namafail = input_data.original_filename
> self.content_type = input_data.content_type.chomp
> self.binary_data = input_data.read
> end
>
> View:
>
> <% form_for(:pelajar, @pelajar, :url => {:action=>'create'}, :html=> 
> {:multipart=>true}) do |f| %>
>
> Fotor :<%= f.file_field :image_file %>
>
> <%= f.submit "Simpan"%>
>
> Sedangkan Untuk menampilkan foto tersebut saya gunakan sintax:
>
> <%= image_tag("/pelajars/code_image/#[email protected] 
> <mailto:%2Fpelajars%2Fcode_image%2F%23%7B%40pelajar.id>}", :alt => 
> "Image") %>
>
> Nah, Kalo kita ingin menyimpan file seperti: pdf,doc,ppt dll Apakah 
> sama sintax seperti tersebut diatas...?
> Terus gimana caranya supaya kita bisa mendowload file2 yang tersimpan 
> tersebut...?
>
> Mohon pencerahan...ya...:)
>
> Thanks...
>
> Zen
>
> [Non-text portions of this message have been removed]
>
> 

Kirim email ke