Closes #147: fix IE file upload

This commit is contained in:
bgamard 2017-11-09 14:39:25 +01:00
parent 36b4fbd303
commit 2957034286
8 changed files with 16 additions and 37 deletions

View File

@ -148,7 +148,7 @@ angular.module('docs').controller('DocumentEdit', function($rootScope, $scope, $
var file = $scope.newFiles[key]; var file = $scope.newFiles[key];
var formData = new FormData(); var formData = new FormData();
formData.append('id', data.id); formData.append('id', data.id);
formData.append('file', file); formData.append('file', file, file.name);
// Send the file // Send the file
$.ajax({ $.ajax({

View File

@ -39,7 +39,7 @@ angular.module('docs').controller('SettingsConfig', function($scope, $rootScope,
$scope.sendImage = function(type, image) { $scope.sendImage = function(type, image) {
// Build the payload // Build the payload
var formData = new FormData(); var formData = new FormData();
formData.append('image', image); formData.append('image', image[0]);
// Send the file // Send the file
var done = function() { var done = function() {

View File

@ -1,20 +0,0 @@
'use strict';
/**
* File upload directive.
*/
angular.module('docs').directive('file', function() {
return {
restrict: 'E',
template: '<input type="file" />',
replace: true,
require: 'ngModel',
link: function(scope, element, attrs, ctrl) {
element.bind('change', function() {
scope.$apply(function() {
attrs.multiple ? ctrl.$setViewValue(element[0].files) : ctrl.$setViewValue(element[0].files[0]);
});
});
}
}
});

View File

@ -79,7 +79,6 @@
<script src="app/docs/service/User.js" type="text/javascript"></script> <script src="app/docs/service/User.js" type="text/javascript"></script>
<script src="app/docs/filter/Newline.js" type="text/javascript"></script> <script src="app/docs/filter/Newline.js" type="text/javascript"></script>
<script src="app/docs/filter/Filesize.js" type="text/javascript"></script> <script src="app/docs/filter/Filesize.js" type="text/javascript"></script>
<script src="app/docs/directive/File.js" type="text/javascript"></script>
<script src="app/docs/directive/SelectTag.js" type="text/javascript"></script> <script src="app/docs/directive/SelectTag.js" type="text/javascript"></script>
<script src="app/docs/directive/SelectRelation.js" type="text/javascript"></script> <script src="app/docs/directive/SelectRelation.js" type="text/javascript"></script>
<script src="app/docs/directive/AuditLog.js" type="text/javascript"></script> <script src="app/docs/directive/AuditLog.js" type="text/javascript"></script>

View File

@ -70,12 +70,12 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label" for="inputFiles">{{ 'document.edit.new_files' | translate }}</label> <label class="col-sm-2 control-label" for="inputFiles">{{ 'document.edit.new_files' | translate }}</label>
<div class="col-sm-6"> <div class="col-sm-6">
<file class="form-control" id="inputFiles" multiple="multiple" ng-model="newFiles" ng-disabled="fileIsUploading"></file> <input type="file" ng-file-select class="form-control" id="inputFiles" multiple="multiple" ng-model="newFiles" ng-disabled="fileIsUploading"></input>
</div> </div>
<div class="col-sm-4" ng-if="orphanFiles.length > 0"> <div class="col-sm-4" ng-if="orphanFiles.length > 0">
+ {{ orphanFiles.length }} file{{ orphanFiles.length > 1 ? 's' : '' }} + {{ orphanFiles.length }} file{{ orphanFiles.length > 1 ? 's' : '' }}
{{ 'document.edit.orphan_files' | translate: '{ count: orphanFiles.length }' }} {{ 'document.edit.orphan_files' | translate: '{ count: orphanFiles.length }' }}
</div>{{newFiles}} </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label" for="inputTags">{{ 'document.tags' | translate }}</label> <label class="col-sm-2 control-label" for="inputTags">{{ 'document.tags' | translate }}</label>

View File

@ -72,16 +72,15 @@
<span class="glyphicon glyphicon-move"></span> <span class="glyphicon glyphicon-move"></span>
{{ 'document.view.content.drop_zone' | translate }} {{ 'document.view.content.drop_zone' | translate }}
</p> </p>
</div>
<div class="clearfix"></div> <div class="text-center">
<div class="text-center"> <button class="btn btn-primary" ng-file-select
<button class="btn btn-primary" ng-file-select ng-file-change="fileDropped($files, $event)"
ng-file-change="fileDropped($files, $event)" input-file-multiple="multiple"
input-file-multiple="multiple" ng-multiple="true">
ng-multiple="true"> {{ 'document.view.content.add_files' | translate }}
{{ 'document.view.content.add_files' | translate }} </button>
</button>
</div>
</div> </div>
</div> </div>

View File

@ -40,7 +40,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label" for="inputLogo">{{ 'settings.config.logo' | translate }}</label> <label class="col-sm-2 control-label" for="inputLogo">{{ 'settings.config.logo' | translate }}</label>
<div class="col-sm-2"> <div class="col-sm-2">
<file accept="image/gif,image/png,image/jpg,image/jpeg" <input type="file" ng-file-select accept="image/gif,image/png,image/jpg,image/jpeg"
class="form-control" id="inputLogo" ng-model="logo" ng-disabled="sendingImage" /> class="form-control" id="inputLogo" ng-model="logo" ng-disabled="sendingImage" />
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2">
@ -54,8 +54,8 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-2 control-label" for="inputBackground">{{ 'settings.config.background_image' | translate }}</label> <label class="col-sm-2 control-label" for="inputBackground">{{ 'settings.config.background_image' | translate }}</label>
<div class="col-sm-2"> <div class="col-sm-2">
<file accept="image/gif,image/png,image/jpg,image/jpeg" <input type="file" ng-file-select accept="image/gif,image/png,image/jpg,image/jpeg"
class="form-control" id="inputLogo" ng-model="background" ng-disabled="sendingImage" /> class="form-control" id="inputBackground" ng-model="background" ng-disabled="sendingImage" />
</div> </div>
<div class="col-sm-2"> <div class="col-sm-2">
<button class="btn btn-default" ng-click="sendImage('background', background)" ng-disabled="sendingImage || !background"> <button class="btn btn-default" ng-click="sendImage('background', background)" ng-disabled="sendingImage || !background">

View File

@ -268,6 +268,7 @@ input[readonly].share-link {
// Vertical alignment // Vertical alignment
.vertical-center { .vertical-center {
min-height: 100vh; min-height: 100vh;
height: 100vh; /* IE fix */
/* Make it a flex container */ /* Make it a flex container */
display: -webkit-box; display: -webkit-box;