34 lines
986 B
PHP
34 lines
986 B
PHP
<?php
|
|
|
|
if (isset($_POST['image'])) {
|
|
|
|
$data = $_POST['image'] ;
|
|
$data = str_replace(' ','+',$data);
|
|
$data = str_replace('data:image/png;base64,', '', $data);
|
|
$img = base64_decode($data);
|
|
|
|
// Effacer l'image et la miniature jpg
|
|
if (file_exists('../../../site/file/thumb/screenshot.jpg')) {
|
|
chmod('../../../site/file/thumb/screenshot.jpg', 0777);
|
|
unlink ('../../../site/file/thumb/screenshot.jpg');
|
|
}
|
|
if (file_exists('../../../site/file/source/screenshot.jpg')) {
|
|
chmod('../../../site/file/source/screenshot.jpg', 0777);
|
|
unlink ('../../../site/file/source/screenshot.jpg');
|
|
}
|
|
|
|
file_put_contents('screenshot.png',$img) ;
|
|
|
|
$image = imagecreatefrompng('screenshot.png');
|
|
$quality = 75;
|
|
imagejpeg($image, '../../../site/file/source/screenshot.jpg', $quality);
|
|
|
|
if (file_exists('screenshot.png')) {
|
|
chmod('screenshot.png', 0777);
|
|
unlink ('screenshot.png');
|
|
}
|
|
|
|
imagedestroy($image);
|
|
}
|
|
?>
|
|
|