Plugin attachment_fu atau paperclip masih asing bagi saya. Udah saya coba2, namum belum berhasil. Trus kalo saya lanjutkan pake blob, gimana caranya.. supaya bisa download file..? field file type memang sudah ada (content_ type). Apa yang harus saya kerjakan lagi..? Saya cari2 di google belum dapat juga. Please..tolong ya..
Zen ________________________________ From: Ahmad Gozali <[email protected]> To: [email protected] Sent: Monday, March 30, 2009 1:56:25 PM Subject: Re: [id-ruby] Gimana cara Download file yang tersipan dalam binary mysql..? 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/menyimpa n 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/#{@ pelajar.id > <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] > > [Non-text portions of this message have been removed]

