summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-04-03 11:15:52 +0200
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-04-03 11:15:52 +0200
commita7bf9306d3844acd160034bb5c64e1ca7ef77ddc (patch)
tree2862ebc4c319b0d48f73173e8f2da58f61e1a319
parent237b627bf6cdf31e8923fc67653a73b6b9978540 (diff)
Test
-rw-r--r--client/js/controllers/image/upload.js2
-rw-r--r--client/js/services/Image.js12
-rw-r--r--client/partials/image/upload.html14
-rwxr-xr-xserver/core/Image.php9
m---------server/vendor/php-opencloud/openstack0
5 files changed, 21 insertions, 16 deletions
diff --git a/client/js/controllers/image/upload.js b/client/js/controllers/image/upload.js
index eca9406..d9587d0 100644
--- a/client/js/controllers/image/upload.js
+++ b/client/js/controllers/image/upload.js
@@ -56,5 +56,5 @@ mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity',
};
-
+ $scope.token=Identity.getToken();
}]);
diff --git a/client/js/services/Image.js b/client/js/services/Image.js
index d6c9fed..4947a1d 100644
--- a/client/js/services/Image.js
+++ b/client/js/services/Image.js
@@ -47,11 +47,11 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){
var uploadImage=function(fileToUpload, callback) {
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')
+ 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);
$.ajax({
@@ -68,7 +68,7 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){
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")
+ alert("success");
}
});
diff --git a/client/partials/image/upload.html b/client/partials/image/upload.html
index 72a8e01..3120fe9 100644
--- a/client/partials/image/upload.html
+++ b/client/partials/image/upload.html
@@ -12,11 +12,15 @@
<div class="modal-body">
-
-
- Choose a file to upload: <input id="imageToUpload" name="uploaded_file" type="file" />
- <input type="submit" value="Upload" />
-
+ <form action="../server/index.php" method="post">
+ <input type="hidden" name="task" value="image" />
+ <input type="hidden" name="token" value="{{ token }}" />
+ <input type="hidden" name="action" value="uploadImage" />
+ <input type="hidden" name="id" value="2564" />
+ <input type="hidden" name="file_name" type="fichier" />
+ <input name="file" type="file" />
+ <input type="submit" value="Upload" />
+ </form>
<div class="modal-footer">
<!--<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>-->
diff --git a/server/core/Image.php b/server/core/Image.php
index c595135..59f7aed 100755
--- a/server/core/Image.php
+++ b/server/core/Image.php
@@ -389,8 +389,9 @@ class image implements Core{
private function uploadImage(){
$id = $this->app->getPostParam("id");
$file_name = $this->app->getPostParam("file_name");
-
-
+ $file = $this->app->getPostParam("file");
+ error_log(print_r($file, true), 0);
+
if(!isset($id)){
$this->app->setOutput("Error", "Incorrect id parameter");
}
@@ -405,7 +406,7 @@ class image implements Core{
if($image == null){ // if the image don't exists -> error
$this->app->setOutput("Error", "Image doesn't exist");
}
- $stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r'));
+ $stream = \GuzzleHttp\Psr7\stream_for($file);
$image->uploadData($stream);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
@@ -684,4 +685,4 @@ class image implements Core{
}
}
-?> \ No newline at end of file
+?>
diff --git a/server/vendor/php-opencloud/openstack b/server/vendor/php-opencloud/openstack
-Subproject 61626420361a1dab3ed6f9455e1057bda18cc33
+Subproject e140ef5ee8f47c5ffa126a581d9e03700a5cdc2