Skip to content

Add pr #876 examples #879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>