पर लिखते हैं, मैं अपने रेल 3 ऐप में फोटो अपलोड करने के लिए Ajax-Upload को लागू करने पर काम कर रहा हूं। प्रलेखन कहते हैं:रेल 3 को कच्चे पोस्ट डेटा मिलते हैं और इसे tmp फ़ाइल
For IE6-8, Opera, older versions of other browsers you get the file as you normally do with regular form-base uploads.
For browsers which upload file with progress bar, you will need to get the raw post data and write it to the file.
तो, कैसे मैं अपने नियंत्रक में कच्चे पद डेटा प्राप्त है और यह एक tmp फ़ाइल पर लिखने तो मेरे नियंत्रक तो यह प्रोसेस कर सकते हैं कर सकते हैं? कुछ अतिरिक्त जानकारी (मेरे मामले में नियंत्रक कुछ छवि हेरफेर कर रहा है और एस 3 के लिए बचत।)
:
मैं सही कॉन्फ़िगर किया गया कर रहा हूँ के रूप में अब के बाद इन मानकों से गुजर रहा है:
Parameters:
{"authenticity_token"=>"...", "qqfile"=>"IMG_0064.jpg"}
... और बनाएं कार्रवाई इस तरह दिखता है:
def create
@attachment = Attachment.new
@attachment.user = current_user
@attachment.file = params[:qqfile]
if @attachment.save!
respond_to do |format|
format.js { render :text => '{"success":true}' }
end
end
end
... लेकिन मैं इस त्रुटि मिलती है:
ActiveRecord::RecordInvalid (Validation failed: File file name must be set.):
app/controllers/attachments_controller.rb:7:in `create'
मैंने अभी रेलवे में AJAX अपलोड का एक उदाहरण जारी किया है 3 + यहां अपलोड करें: https://github.com/apneadiving/Pic-upload---Crop-in-Ajax। उम्मीद है कि यह – apneadiving