하지 않을 때 나는 내가 'WAV와 같은 파일을 업로드 할 때종이 클립 :: NotIdentifiedByImageMagickError 파일이 올바른 첨부 파일 콘텐츠 유형
["image/jpg", "image/jpeg", "image/gif", "image/png", "image/pjpeg", "image/x-png"]
에없는 파일을 업로드하기 위해 노력하고있어 체계적으로 오류가 '나는이 메시지를
* Photo /var/folders/nT/nTr21TWfFRO7r3cyG-h-7++++TM/-Tmp-/Clip audio 01,39154,0.wav is not recognized by the 'identify' command. * Photo /var/folders/nT/nTr21TWfFRO7r3cyG-h-7++++TM/-Tmp-/Clip audio 01,39154,0.wav is not recognized by the 'identify' command. * Photo content type Accepted files include: jpg, gif, png
이는 그래서 파일이 이미지하지 않고 내 메시지 "Accepted files include: jpg, gif, png"
를 표시 있음을 감지하지만 난 내 사진 전에 포함이 여분의 메시지가 인식하지 못하는가'확인 '명령 .. . 그림 업로드가 잘 작동합니다.
내 코드는 다음과 같습니다
컨트롤러 :
def upload
@picture= Picture.new(params[:picture])
if [email protected]?
render :form
end
end
보기 양식 :
<%= error_messages_for :picture, :header_message => nil, :message => nil %>
<% form_for :picture, @picture, :name => "uploadPic", :url => { :action => 'upload_data'}, :html => {:name => 'uploadForm', :multipart => true } do |form| %>
<%= form.file_field :photo %>
<%= submit_tag 'Save'%>
<% end %>
사진 모델 :
,536,913,632class Picture < ActiveRecord::Base
require 'paperclip'
has_attached_file :photo, :styles => { :medium => "300x300>", :thumb => "100x100>" }
validates_attachment_size :photo, :less_than => 2.megabytes , :message => "must be less than 2 megabytes"
validates_attachment_content_type :photo, :content_type => ["image/jpg", "image/jpeg", "image/gif", "image/png", "image/pjpeg", "image/x-png"], :message => "Accepted files include: jpg, gif, png"
end
수정 사항을 사용할 때 : 중간 및 : 썸 이미지, 그냥 : 원본 – Artur79