Fix drag upload bug.
This commit is contained in:
parent
d401049a92
commit
3ad002bdf1
|
@ -82,6 +82,17 @@ class Admin::ArchiveFilesController < OrbitAdminController
|
|||
render :partial => "categories_order" if request.xhr?
|
||||
end
|
||||
def create
|
||||
params["archive_file"]["archive_file_multiples_attributes"].each do |k,v|
|
||||
if v["file"].class == String
|
||||
file_content_info = JSON.parse(v["file"])
|
||||
content_type = file_content_info["type"]
|
||||
filename = file_content_info["name"]
|
||||
head = "Content-Disposition: form-data; name=\"archive_file[archive_file_multiples_attributes][#{k}][file]\"; filename=\"#{filename}\" Content-Type: #{content_type}"
|
||||
tempfile = Tempfile.new(filename,binmode: true)
|
||||
tempfile.write(file_content_info["content"].unpack('U*').map{|i| i.chr }.join)
|
||||
v["file"] = ActionDispatch::Http::UploadedFile.new({:filename=>filename,:type=>content_type,:head=>head,:tempfile=>tempfile})
|
||||
end
|
||||
end rescue nil
|
||||
@archive_file = ArchiveFile.new(archive_vars)
|
||||
@archive_file.create_user_id = current_user.id
|
||||
@archive_file.update_user_id = current_user.id
|
||||
|
|
|
@ -249,6 +249,9 @@
|
|||
}
|
||||
function FileListItems (files) {
|
||||
var b;
|
||||
try{
|
||||
b = new DataTransfer();
|
||||
}catch(e){
|
||||
if(window.dataTransfer){
|
||||
b = window.dataTransfer;
|
||||
}else{
|
||||
|
@ -258,6 +261,7 @@
|
|||
b = new ClipboardEvent("").clipboardData;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(b.items){
|
||||
b.items.clear();
|
||||
}else{
|
||||
|
|
Loading…
Reference in New Issue