Test
This commit is contained in:
parent
237b627bf6
commit
a7bf9306d3
5 changed files with 22 additions and 17 deletions
|
@ -56,5 +56,5 @@ mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity',
|
|||
|
||||
};
|
||||
|
||||
|
||||
$scope.token=Identity.getToken();
|
||||
}]);
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -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>-->
|
||||
|
|
|
@ -389,7 +389,8 @@ 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);
|
||||
|
|
2
server/vendor/php-opencloud/openstack
vendored
2
server/vendor/php-opencloud/openstack
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 61626420361a1dab3ed6f9455e1057bda18cc335
|
||||
Subproject commit e140ef5ee8f47c5ffa126a581d9e03700a5cdc2f
|
Loading…
Add table
Reference in a new issue