diff options
| author | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2016-03-21 06:47:01 +0100 |
|---|---|---|
| committer | manzerbredes <loic.guegan_secondary@yahoo.fr> | 2016-03-21 06:47:01 +0100 |
| commit | 3c336f00d29ba927d41e2029a3c1d893cee43f9d (patch) | |
| tree | c5492a51fed5f2d2e36d484c56c878198fd3ef87 /client/js/services/Image.js | |
| parent | 3216a69b752e8d8129913d24ced4cffbd794fef2 (diff) | |
Add login check witouth reloading page
Diffstat (limited to 'client/js/services/Image.js')
| -rw-r--r-- | client/js/services/Image.js | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/client/js/services/Image.js b/client/js/services/Image.js index decb5b2..d427e51 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -45,17 +45,42 @@ 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'})); + var form_data = new FormData(); + form_data.append('file', fileToUpload); + console.log(fileToUpload) + form_data.append("task" , "image") + form_data.append("token" , Identity.getToken()) + form_data.append('action',"uploadImage") + form_data.append('id','6564') + form_data.append('file_name', fileToUpload.name); + + $.ajax({ + url: "../server/index.php", // Url to which the request is send + type: "POST", // Type of request to be send, called as method + data: form_data, // Data sent to server, a set of key/value pairs (i.e. form fields and values) + file_name:fileToUpload.name, + token : Identity.getToken(), + task : "image", + action:'uploadImage', + id:'6564', + contentType: false, // The content type used when sending data to the server. + cache: false, // To unable request pages to be cached + processData:false, // To send DOMDocument or non processed data file it is set to false + success: function(data) // A function to be called if request succeeds + { + alert("success") + } + }); + + //var result=$http.post('../server/index.php', + // $.param({"token" : Identity.getToken(), "task" : "image", 'action':'uploadImage', 'file_name':form_data, 'id':'6564'})); // Wait and handle the response - result.then(function (response){ + /* result.then(function (response){ callback(parseUploadImageAnswer(response, false)); },function(response){ callback(parseUploadImageAnswer(response, true)); - }); + });*/ |
