|
@@ -77,21 +77,19 @@ switch($_['action']){
|
|
global $myUser,$_;
|
|
global $myUser,$_;
|
|
|
|
|
|
require_once(__DIR__.SLASH.'Sketch.class.php');
|
|
require_once(__DIR__.SLASH.'Sketch.class.php');
|
|
-
|
|
|
|
|
|
+ if(!is_numeric($_['sketch'])) throw new Exception("Sketch non spécifié", 400);
|
|
$sketch = Sketch::provide('sketch');
|
|
$sketch = Sketch::provide('sketch');
|
|
- if($myUser->login!=$sketch->creator) throw new Exception("Pemrission insuffisantes", 403);
|
|
|
|
|
|
+ if($myUser->login!= $sketch->creator) throw new Exception("Permission insuffisantes", 403);
|
|
|
|
|
|
$folder = $sketch->directory();
|
|
$folder = $sketch->directory();
|
|
-
|
|
|
|
if(!file_exists($folder)) mkdir($folder,0755,true);
|
|
if(!file_exists($folder)) mkdir($folder,0755,true);
|
|
-
|
|
|
|
-
|
|
|
|
$name = 'cover.jpg';
|
|
$name = 'cover.jpg';
|
|
|
|
|
|
- $stream = preg_replace('|data\:image/[^;];base64,|is','',$_['stream']);
|
|
|
|
-
|
|
|
|
- $row = file_put_contents($folder.SLASH.$name, base64_decode($stream));
|
|
|
|
-
|
|
|
|
|
|
+ $stream = preg_replace('|data\:image\/[^;]*;base64,|is','',$_['stream']);
|
|
|
|
+ $filepath = $folder.SLASH.$name;
|
|
|
|
+ $row = file_put_contents($filepath, base64_decode($stream));
|
|
|
|
+ Image::resize($filepath,150,150);
|
|
|
|
+ $response['stream'] = 'data:image/jpg;base64,'.base64_encode(file_get_contents($filepath));
|
|
|
|
|
|
});
|
|
});
|
|
break;
|
|
break;
|