-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #879 from ygj6/master
Add pr #876 examples
- Loading branch information
Showing
3 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |