tôi đã cố gắng uploadify
với carrierwave
để hỗ trợ multiple file upload
nhưng nó cho tôi lỗi này GET http://localhost:3000/users/uploadify.swf?preventswfcaching=1361694618739
. Về cơ bản tôi đã có một model
có tên là user
. Đối với tải lên duy nhất nó làm việc tốt với carrierwave nhưng đối với nhiều tập tin nó không phải là.lỗi tải lên khi sử dụng carrierwave và tải lên
Tôi đã theo dõi this hướng dẫn. Trong users/_form.rb
<p>
<%= f.label "Upload Images"%>
<%= f.file_field :image, :multiple => true %>
</p>
<script type= "text/javascript">
$(document).ready(function() {
<% key = Rails.application.config.session_options[:key] %>
var uploadify_script_data = {};
var csrf_param = $('meta[name=csrf-param]').attr('content');
var csrf_token = $('meta[name=csrf-token]').attr('content');
uploadify_script_data[csrf_param] = encodeURI(encodeURIComponent(csrf_token));
uploadify_script_data['<%= key %>'] = '<%= cookies[key] %>';
$('#user_image').uploadify({
uploader : '<%= asset_path("uploadify.swf")%>',
script : '/images',
cancelImg : '<%= asset_path("uploadify-cancel.png")%>',
auto : true,
multi : true,
removeCompleted : true,
scriptData : uploadify_script_data,
onComplete : function(event, ID, fileObj, doc, data) {
}
});
});
</script>
Tôi đang sử dụng mongoid vì thế mô hình là như thế này
class User
include Mongoid::Document
field :name, type: String
field :description, type: String
field :image, type: String
mount_uploader :image, ImageUploader
end
tôi đang không nhận được báo lỗi là gì. Hãy giúp tôi ra.
Bạn chỉ đăng yêu cầu GET, chứ không phải lỗi thực tế. Vui lòng đăng lỗi. – Jesper
nó là lỗi i m nhận được trong giao diện điều khiển js. Trên thực tế nút duyệt tệp không hoạt động. –
Hãy hiểu rằng 'GET http: // localhost: 3000/users/uploadify.swf? Preventwfcaching = 1361694618739' không phải là lỗi, nó chỉ đơn giản là một câu lệnh. Vui lòng cung cấp cho chúng tôi lỗi thực tế. – Jesper