Skip to content

Commit

Permalink
Merge pull request #879 from ygj6/master
Browse files Browse the repository at this point in the history
Add pr #876 examples
  • Loading branch information
yuangongji authored Jul 3, 2020
2 parents 906303a + e4b0481 commit da9e112
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 0 deletions.
33 changes: 33 additions & 0 deletions examples/issues/pr876/controllers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';
angular
.module('app', ['angularFileUpload'])
.controller('AppController', ['$scope', 'FileUploader', function ($scope, FileUploader) {
var uploader = $scope.uploader = new FileUploader({
url: '../upload.php'
});

$scope.upload = function () {
var items = uploader.getNotUploadedItems();
if (items.length == 0) {
console.log("No files to upload");
return false;
}

for (var i = 0; i < items.length; i++) {
var fileItem = changeFileName(items[i], "");
fileItem.upload();
}
};

function changeFileName(fileItem, newFileName) {
newFileName = newFileName || "file" + new Date().getTime();

var fileName = fileItem.file.name.split('.');
if (fileName.length < 2) {
alert("Uploaded file must have a valid extension! For more information see the Supported Formats")
}
var fileExtension = "." + fileName.pop();
fileItem.file.name = newFileName + fileExtension;
return fileItem;
}
}]);
26 changes: 26 additions & 0 deletions examples/issues/pr876/iframe.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html id="ng-app" ng-app="app"> <!-- id="ng-app" IE<8 -->

<head>
<title>Simple example</title>
<!-- Fix for old browsers -->
<script src="http://nervgh.github.io/js/es5-shim.min.js"></script>
<script src="http://nervgh.github.io/js/es5-sham.min.js"></script>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="../../console-sham.js"></script>

<!--<script src="../bower_components/angular/angular.js"></script>-->
<script src="http://code.angularjs.org/1.2.0/angular.min.js"></script>
<script src="../../../dist/angular-file-upload.js"></script>
<script src="controllers.js"></script>
</style>

</head>
<body ng-controller="AppController" uploader="uploader">
<a href="javascript:;" class="file_a">
<input type="file" name="file1" nv-file-select uploader="uploader" />
</a>
<button ng-click="upload()">Upload</button>

</body>
</html>
12 changes: 12 additions & 0 deletions examples/issues/pr876/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>

<head>
<title>Simple example</title>
</head>

<body>
<iframe src="iframe.html"></iframe>
</body>

</html>

0 comments on commit da9e112

Please sign in to comment.