summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]client/partials/image/edit.html2
-rwxr-xr-xserver/core/Image.php25
2 files changed, 23 insertions, 4 deletions
diff --git a/client/partials/image/edit.html b/client/partials/image/edit.html
index 734da7f..8c1575c 100644..100755
--- a/client/partials/image/edit.html
+++ b/client/partials/image/edit.html
@@ -34,7 +34,7 @@
</fieldset>
</form>
- <form action="../server/index.php" method="post" ng-if='image.status == "queued"'>
+ <form action="../server/index.php" enctype="multipart/form-data" method="post" ng-if='image.status == "queued"'>
<input type="hidden" name="task" value="image" />
<input type="hidden" name="token" value="{{ getToken()}}" />
<input type="hidden" name="action" value="uploadImage" />
diff --git a/server/core/Image.php b/server/core/Image.php
index 60f6d98..ac967d5 100755
--- a/server/core/Image.php
+++ b/server/core/Image.php
@@ -388,9 +388,28 @@ 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);
+ $file_name = $_FILES['file']['name'];
+ $file_error = $_FILES['file']['error'];
+ $file_tmp = $_FILES['file']['tmp_name'];
+
+ switch($file_error){
+ case UPLOAD_ERR_INI_SIZE:
+ $this->app->setOutput("Error", "File Size exceeds Maximum");
+ return;
+ case UPLOAD_ERR_FORM_SIZE:
+ case UPLOAD_ERR_PARTIAL:
+ $this->app->setOutput("Error", "Incorrect id parameter");
+ return;
+ case UPLOAD_ERR_NO_FILE:
+ $this->app->setOutput("Error", "File Upload incomplete");
+ return;
+ }
+ if( !is_uploaded_file($file_tmp) )
+ {
+ $this->app->setOutput("Error", "File Upload Error");
+ return;
+ }
if(!isset($id)){
$this->app->setOutput("Error", "Incorrect id parameter");
@@ -405,7 +424,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($file);
+ $stream = \GuzzleHttp\Psr7\stream_for(fopen($file_tmp, 'r'));
$image->uploadData($stream);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);