1
나는 응용 프로그램에 이미지를 업로드하기위한 jquery-fileupload-rails
보석을 사용하고 있습니다. 파일 업로드 후 진행 막대가 제거되지 않습니다. jquery 파일 업로드
<div class="photo-post-img">
<%= form_for Upload.new do |f| %>
<span class="btn btn-primary fileinput-button ml30">
<b>+</b>
<span class="text-orange">Add image</span>
<%= f.file_field :upload, multiple: true, name: "upload[upload]" %>
<%= f.hidden_field :post_id, :value => @post.upload_id %>
<%= f.hidden_field :upload_type, :value => @post.upload_type %>
</span>
<% end %>
<div class="img-upload-list">
<ul id="photos_uploaded" class="thumbnails pull-left">
<% @post.uploads.each do |upload| %>
<li class="thumbnail" id="uploads-<%=upload.id %>">
<%=image_tag upload.upload.url(:medium) %>
<%= link_to "Delete", upload, :remote => true, :method => "delete" %>
</li>
<% end %>
</ul>
</div>
와의 .js 파일에
<script id="template-upload" type="text/x-tmpl">
<div class="upload ">
{%=o.name%}
<div class="progress"><div class="bar" style="width: 0%"></div></div>
: 모든 것이 작동
jQuery(function() {
return $('#new_upload').fileupload({
dataType: "script",
add: function(e, data) {
var file, types;
types = /(\.|\/)(gif|jpe?g|png)$/i;
file = data.files[0];
if (types.test(file.type) || types.test(file.name)) {
data.context = $(tmpl("template-upload", file));
$('#new_upload').append(data.context);
return data.submit();
} else {
return alert("" + file.name + " is not a gif, jpeg, or png image file");
}
},
progress: function(e, data) {
var progress;
if (data.context) {
progress = parseInt(data.loaded/data.total * 100, 10);
return data.context.find('.bar').css('width', progress + '%');
}
},
done: function (e, data) {
$('.upload').attr('style', 'visibility: hidden');
}
});
});
잘하지만 이미지 업로드 후, 진행 표시 줄이 제거되지 않습니다 여기 코드입니다 . 업로드 후 막대를 제거하는 방법은 무엇입니까? 대신
done
콜백의
작품을 접수하여 JS에서
stop
콜백을 추가합니다. 하지만 여러 파일 업로드를 허용하도록 설정 한 경우 사용자가 몇 개의 파일을 업로드한다고 말합니다. 일괄 처리 워터 마킹과 같이 구현되는 모든 작업을 수행합니다. 업로드를 진행하면 진행률 표시 줄이 표시되지 않습니다. –