7
7
8
8
var angularFileUpload = angular . module ( 'angularFileUpload' , [ ] ) ;
9
9
10
- angularFileUpload . service ( '$upload' , [ '$http' , '$rootScope' , '$ timeout', function ( $http , $rootScope , $timeout ) {
10
+ angularFileUpload . service ( '$upload' , [ '$http' , '$timeout' , function ( $http , $timeout ) {
11
11
function sendHttp ( config ) {
12
12
config . method = config . method || 'POST' ;
13
13
config . headers = config . headers || { } ;
@@ -66,20 +66,21 @@ angularFileUpload.service('$upload', ['$http', '$rootScope', '$timeout', functio
66
66
} ) ( promise , promise . then ) ;
67
67
68
68
return promise ;
69
- } ;
69
+ }
70
70
this . upload = function ( config ) {
71
71
config . headers = config . headers || { } ;
72
72
config . headers [ 'Content-Type' ] = undefined ;
73
73
config . transformRequest = config . transformRequest || $http . defaults . transformRequest ;
74
74
var formData = new FormData ( ) ;
75
+ var i ;
75
76
if ( config . data ) {
76
77
for ( var key in config . data ) {
77
78
var val = config . data [ key ] ;
78
79
if ( ! config . formDataAppender ) {
79
80
if ( typeof config . transformRequest == 'function' ) {
80
81
val = config . transformRequest ( val ) ;
81
82
} else {
82
- for ( var i = 0 ; i < config . transformRequest . length ; i ++ ) {
83
+ for ( i = 0 ; i < config . transformRequest . length ; i ++ ) {
83
84
var fn = config . transformRequest [ i ] ;
84
85
if ( typeof fn == 'function' ) {
85
86
val = fn ( val ) ;
@@ -98,7 +99,7 @@ angularFileUpload.service('$upload', ['$http', '$rootScope', '$timeout', functio
98
99
99
100
if ( Object . prototype . toString . call ( config . file ) === '[object Array]' ) {
100
101
var isFileFormNameString = Object . prototype . toString . call ( fileFormName ) === '[object String]' ;
101
- for ( var i = 0 ; i < config . file . length ; i ++ ) {
102
+ for ( i = 0 ; i < config . file . length ; i ++ ) {
102
103
formData . append ( isFileFormNameString ? fileFormName + i : fileFormName [ i ] , config . file [ i ] , config . file [ i ] . name ) ;
103
104
}
104
105
} else {
@@ -114,7 +115,7 @@ angularFileUpload.service('$upload', ['$http', '$rootScope', '$timeout', functio
114
115
}
115
116
} ] ) ;
116
117
117
- angularFileUpload . directive ( 'ngFileSelect' , [ '$parse' , '$http' , '$ timeout', function ( $parse , $http , $timeout ) {
118
+ angularFileUpload . directive ( 'ngFileSelect' , [ '$parse' , '$timeout' , function ( $parse , $timeout ) {
118
119
return function ( scope , elem , attr ) {
119
120
var fn = $parse ( attr [ 'ngFileSelect' ] ) ;
120
121
elem . bind ( 'change' , function ( evt ) {
@@ -138,7 +139,7 @@ angularFileUpload.directive('ngFileSelect', [ '$parse', '$http', '$timeout', fun
138
139
} ;
139
140
} ] ) ;
140
141
141
- angularFileUpload . directive ( 'ngFileDropAvailable' , [ '$parse' , '$http' , '$ timeout', function ( $parse , $http , $timeout ) {
142
+ angularFileUpload . directive ( 'ngFileDropAvailable' , [ '$parse' , '$timeout' , function ( $parse , $timeout ) {
142
143
return function ( scope , elem , attr ) {
143
144
if ( 'draggable' in document . createElement ( 'span' ) ) {
144
145
var fn = $parse ( attr [ 'ngFileDropAvailable' ] ) ;
@@ -149,7 +150,7 @@ angularFileUpload.directive('ngFileDropAvailable', [ '$parse', '$http', '$timeou
149
150
} ;
150
151
} ] ) ;
151
152
152
- angularFileUpload . directive ( 'ngFileDrop' , [ '$parse' , '$http' , '$ timeout', function ( $parse , $http , $timeout ) {
153
+ angularFileUpload . directive ( 'ngFileDrop' , [ '$parse' , '$timeout' , function ( $parse , $timeout ) {
153
154
return function ( scope , elem , attr ) {
154
155
if ( 'draggable' in document . createElement ( 'span' ) ) {
155
156
var cancel = null ;
0 commit comments