-
-
Save evenchange4/276f0957a95b4c4bdf46 to your computer and use it in GitHub Desktop.
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
uploader = $fileUploader.create( | |
scope: $scope | |
url: "http://#{$rootScope.api}/proposal/upload" | |
formData: [{ | |
key: \value | |
}] | |
filters: [ | |
(item) -> | |
if item.size >10000000 | |
alert \size不得超過10mb | |
false | |
else | |
true | |
] | |
) | |
uploader.filters.push (item) -> | |
true | |
$scope.picPool = [] | |
uploader.bind \progress, (event, item, progress) -> | |
console.info \Progress: + progress, item | |
uploader.bind \beforeupload, (event, item)-> | |
console.info 'Before upload', item | |
uploader.bind \complete, (event, xhr, item)-> | |
_x = angular.fromJson xhr.response | |
$scope.change = true | |
if _x.n == \error | |
alert \上傳圖片需為2000x1500px | |
else | |
$scope.picPool.push {u:_x.n,m:0} | |
$scope.oi = false | |
$scope.mainpic = $scope.picPool[0].u | |
_ym = 0 | |
for v in $scope.picPool | |
if v.m == 1 | |
_ym = 1 | |
if _ym == 0 | |
$scope.picPool[0].m = 1 | |
uploader.bind \completeall, (event, items) !-> | |
$scope.oi = false | |
$scope.uploader = uploader |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment