test
This commit is contained in:
parent
3b569b6d00
commit
8ad216dedf
4 changed files with 32 additions and 3 deletions
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
<!-- Include JQuery -->
|
<!-- Include JQuery -->
|
||||||
<script src="./vendors/jquery/jquery-2.2.0.min.js"></script>
|
<script src="./vendors/jquery/jquery-2.2.0.min.js"></script>
|
||||||
|
|
||||||
<!-- Include Bootstrap -->
|
<!-- Include Bootstrap -->
|
||||||
<script src="./vendors/bootstrap/js/bootstrap.min.js"></script>
|
<script src="./vendors/bootstrap/js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* @param {$scope} $scope The $scope service from angular
|
* @param {$scope} $scope The $scope service from angular
|
||||||
*/
|
*/
|
||||||
mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', function ($scope, Image, Loading)
|
mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading',function ($scope, Image, Loading)
|
||||||
{
|
{
|
||||||
var callbackTest=function(){
|
var callbackTest=function(){
|
||||||
$scope.images=Image.getData().images;
|
$scope.images=Image.getData().images;
|
||||||
|
@ -17,5 +17,9 @@ mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', function ($scope,
|
||||||
else{
|
else{
|
||||||
callbackTest();
|
callbackTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.doUpload = function () {
|
||||||
|
Image.uploadImage($scope.myFile,function(){});
|
||||||
|
};
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
|
|
@ -44,6 +44,23 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var uploadImage=function(fileToUpload, callback) {
|
||||||
|
|
||||||
|
|
||||||
|
var result=$http.post('../server/index.php',
|
||||||
|
$.param({"token" : Identity.getToken(), "task" : "image", 'action':'uploadImage', 'filename':fileToUpload, 'id':'6564'}));
|
||||||
|
|
||||||
|
// Wait and handle the response
|
||||||
|
result.then(function (response){
|
||||||
|
callback(parseUploadImageAnswer(response, false));
|
||||||
|
},function(response){
|
||||||
|
callback(parseUploadImageAnswer(response, true));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var getData=function(response){
|
var getData=function(response){
|
||||||
return data;
|
return data;
|
||||||
|
@ -52,7 +69,8 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){
|
||||||
// Return services objects
|
// Return services objects
|
||||||
return {
|
return {
|
||||||
getImages:getImages,
|
getImages:getImages,
|
||||||
getData:getData
|
getData:getData,
|
||||||
|
uploadImage:uploadImage
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,12 @@
|
||||||
<div ng-repeat="image in images">
|
<div ng-repeat="image in images">
|
||||||
{{image.name}}
|
{{image.name}}
|
||||||
</div>
|
</div>
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<input name="myFile" type="file" />
|
||||||
|
<br />
|
||||||
|
<button type="button" ng-click="doUpload()" class="btn btn-primary">Upload</button>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue