加强对chrome浏览器文件上传的支持

This commit is contained in:
nwb 2014-07-22 15:02:58 +08:00
parent 42c2f6c2ee
commit 095cb7fc32
2 changed files with 16 additions and 14 deletions

View File

@ -35,3 +35,5 @@
<% content_for :header_tags do %> <% content_for :header_tags do %>
<%= javascript_include_tag 'attachments' %> <%= javascript_include_tag 'attachments' %>
<% end %> <% end %>

View File

@ -156,12 +156,12 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) {
} }
function addInputFiles(inputEl) { function addInputFiles(inputEl) {
var clearedFileInput = $(inputEl).clone().val(''); // var clearedFileInput = $(inputEl).clone().val('');
if (inputEl.files) { if (inputEl.files) {
// upload files using ajax // upload files using ajax
uploadAndAttachFiles(inputEl.files, inputEl); uploadAndAttachFiles(inputEl.files, inputEl);
$(inputEl).remove(); // $(inputEl).remove();
} else { } else {
// browser not supporting the file API, upload on form submission // browser not supporting the file API, upload on form submission
var attachmentId; var attachmentId;
@ -172,7 +172,7 @@ function addInputFiles(inputEl) {
} }
} }
clearedFileInput.insertAfter('#attachments_fields'); //clearedFileInput.insertAfter('#attachments_fields');
} }
function uploadAndAttachFiles(files, inputEl) { function uploadAndAttachFiles(files, inputEl) {