Skip to content

Commit dc92cb7

Browse files
committed
issue-862 solution
1 parent 7f65dd8 commit dc92cb7

File tree

4 files changed

+187
-0
lines changed

4 files changed

+187
-0
lines changed

examples/issues/862/controllers.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
4+
angular
5+
6+
7+
.module('app', ['angularFileUpload'])
8+
9+
10+
.controller('AppController', ['$scope', 'FileUploader', function($scope, FileUploader) {
11+
var uploader = $scope.uploader = new FileUploader({
12+
url: 'upload.php'
13+
//,timeout: 2000
14+
});
15+
16+
$scope.testUploader = function(){
17+
angular.element("#testUpload").click();
18+
}
19+
20+
uploader.onCompleteAll = function() {
21+
console.info('onCompleteAll');
22+
};
23+
24+
console.info('uploader', uploader);
25+
}]);

examples/issues/862/index.html

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
<!DOCTYPE html>
2+
<html id="ng-app" ng-app="app"> <!-- id="ng-app" IE<8 -->
3+
4+
<head>
5+
<title>Simple example</title>
6+
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
7+
8+
<!-- Fix for old browsers -->
9+
<script src="http://nervgh.github.io/js/es5-shim.min.js"></script>
10+
<script src="http://nervgh.github.io/js/es5-sham.min.js"></script>
11+
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
12+
<script src="../../console-sham.js"></script>
13+
14+
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
15+
16+
<!--<script src="../bower_components/angular/angular.js"></script>-->
17+
<script src="http://code.angularjs.org/1.2.0/angular.min.js"></script>
18+
<script src="../../../dist/angular-file-upload.min.js"></script>
19+
<script src="controllers.js"></script>
20+
21+
<style>
22+
.my-drop-zone { border: dotted 3px lightgray; }
23+
.nv-file-over { border: dotted 3px red; } /* Default class applied to drop zones on over */
24+
.another-file-over-class { border: dotted 3px green; }
25+
26+
html, body { height: 100%; }
27+
.block {
28+
width: 200px;
29+
height: 200px;
30+
display: inline-block;
31+
}
32+
.white {
33+
background-color: white;
34+
}
35+
.main {
36+
background-color: aqua;
37+
}
38+
#testUpload {
39+
display: none;
40+
}
41+
</style>
42+
43+
</head>
44+
45+
<!-- 1. nv-file-drop="" uploader="{Object}" options="{Object}" filters="{String}" -->
46+
<body ng-controller="AppController" uploader="uploader" filters="queueLimit, customFilter">
47+
48+
<div class="container">
49+
50+
<div class="row">
51+
52+
<div class="col-md-3">
53+
54+
<h3>Select files</h3>
55+
56+
Single
57+
<input id="testUpload" type="file" nv-file-select="" uploader="uploader" /><br/>
58+
59+
<div nv-file-drop="" nv-file-over="" uploader="uploader" ng-click="testUploader();" class="block main">
60+
Alternative upload buttoon
61+
<div>File meta data:name,status</div>
62+
<b>{{ uploader.queue[uploader.queue.length-1].file.name }}</b>
63+
<div>Is also an drag-and-drop area</div>
64+
</div>
65+
66+
</div>
67+
68+
<div class="col-md-9" style="margin-bottom: 40px">
69+
70+
<h3>Upload queue</h3>
71+
<p>Queue length: {{ uploader.queue.length }}</p>
72+
73+
<table class="table">
74+
<thead>
75+
<tr>
76+
<th width="50%">Name</th>
77+
<th ng-show="uploader.isHTML5">Size</th>
78+
<th ng-show="uploader.isHTML5">Progress</th>
79+
<th>Status</th>
80+
<th>Actions</th>
81+
</tr>
82+
</thead>
83+
<tbody>
84+
<tr ng-repeat="item in uploader.queue">
85+
<td><strong>{{ item.file.name }}</strong></td>
86+
<td ng-show="uploader.isHTML5" nowrap>{{ item.file.size/1024/1024|number:2 }} MB</td>
87+
<td ng-show="uploader.isHTML5">
88+
<div class="progress" style="margin-bottom: 0;">
89+
<div class="progress-bar" role="progressbar" ng-style="{ 'width': item.progress + '%' }"></div>
90+
</div>
91+
</td>
92+
<td class="text-center">
93+
<span ng-show="item.isSuccess"><i class="glyphicon glyphicon-ok"></i></span>
94+
<span ng-show="item.isCancel"><i class="glyphicon glyphicon-ban-circle"></i></span>
95+
<span ng-show="item.isError"><i class="glyphicon glyphicon-remove"></i></span>
96+
</td>
97+
<td nowrap>
98+
<button type="button" class="btn btn-success btn-xs" ng-click="item.upload()" ng-disabled="item.isReady || item.isUploading || item.isSuccess">
99+
<span class="glyphicon glyphicon-upload"></span> Upload
100+
</button>
101+
<button type="button" class="btn btn-warning btn-xs" ng-click="item.cancel()" ng-disabled="!item.isUploading">
102+
<span class="glyphicon glyphicon-ban-circle"></span> Cancel
103+
</button>
104+
<button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()">
105+
<span class="glyphicon glyphicon-trash"></span> Remove
106+
</button>
107+
</td>
108+
</tr>
109+
</tbody>
110+
</table>
111+
112+
<div>
113+
<div>
114+
Queue progress:
115+
<div class="progress" style="">
116+
<div class="progress-bar" role="progressbar" ng-style="{ 'width': uploader.progress + '%' }"></div>
117+
</div>
118+
</div>
119+
<button type="button" class="btn btn-success btn-s" ng-click="uploader.uploadAll()" ng-disabled="!uploader.getNotUploadedItems().length">
120+
<span class="glyphicon glyphicon-upload"></span> Upload all
121+
</button>
122+
<button type="button" class="btn btn-warning btn-s" ng-click="uploader.cancelAll()" ng-disabled="!uploader.isUploading">
123+
<span class="glyphicon glyphicon-ban-circle"></span> Cancel all
124+
</button>
125+
<button type="button" class="btn btn-danger btn-s" ng-click="uploader.clearQueue()" ng-disabled="!uploader.queue.length">
126+
<span class="glyphicon glyphicon-trash"></span> Remove all
127+
</button>
128+
</div>
129+
130+
</div>
131+
132+
</div>
133+
134+
</div>
135+
136+
</body>
137+
</html>

examples/issues/862/upload.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
if ( !empty( $_FILES ) ) {
4+
5+
$tempPath = $_FILES[ 'file' ][ 'tmp_name' ];
6+
$uploadPath = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR . $_FILES[ 'file' ][ 'name' ];
7+
8+
move_uploaded_file( $tempPath, $uploadPath );
9+
10+
$answer = array( 'answer' => 'File transfer completed' );
11+
$json = json_encode( $answer );
12+
13+
echo $json;
14+
15+
} else {
16+
17+
echo 'No files';
18+
19+
}
20+
21+
?>

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
"gulp": "~3.9.1",
2424
"json-loader": "~0.5.4",
2525
"raw-loader": "~0.5.1",
26+
"serve": "^11.2.0",
2627
"webpack-stream": "~3.2.0"
28+
},
29+
"scripts": {
30+
"serve": "serve ."
2731
}
2832
}

0 commit comments

Comments
 (0)