示例#1
0
文件: aws.php 项目: rabenmedia/uk
{
    $img = imagecreatefromstring(base64_decode($base64));
    if (!$img) {
        return false;
    }
    return true;
}
// include this file (provided on the standard include path)
require_once 'phpsec/_common/s3/S3ImageStore.php';
// if (!array_key_exists('Filedata',$_FILES))
// 	throw new Exception("Missing upload!");
if (!isset($_POST['image'])) {
    throw new Exception("Missing upload!");
}
// $file=$_FILES['Filedata'];
if (check_base64_image($_POST['image'])) {
    $dataURL = $_POST['image'];
    $parts = explode(',', $dataURL);
    $data = $parts[1];
    $filename = round(microtime(true) * 100);
    // Decode base64 data, resulting in an image
    $data = base64_decode($data);
    // change this
    $envPrefix = "FRANKEN_";
    $store = S3ImageStore::getNew($envPrefix);
    $url = $store->storeImageData($data, $filename);
    if (!$url) {
        throw new Exception($store->getError());
    }
    // do something
    echo json_encode(array('status' => 200, 'url' => $url));
示例#2
0
 $user_pic = str_replace($remove, $replace, $_POST['user_pic']);
 $f_url = $_POST['filter'];
 if (empty($user_pic)) {
     $error[] = 'Image utilisateur manquante';
 }
 if (empty($f_url)) {
     $error[] = 'Filtre utilisateur manquant';
 }
 preg_match('/[^\\/]+$/', $f_url, $img);
 if (!empty($img[0])) {
     $filter = $path . '/public/img/pool/' . $img[0];
 } else {
     $error[] = 'Mauvais filtre.';
 }
 if (empty($error)) {
     if (check_base64_image($user_pic) && file_exists($filter)) {
         // create ressources
         $src = imagecreatefrompng($filter);
         $dest = imagecreatefromstring(base64_decode($user_pic));
         // set alpha
         imagealphablending($dest, true);
         imagesavealpha($dest, false);
         // merge pictures
         imagecopy($dest, $src, 0, 0, 0, 0, 320, 240);
         // save img into galerie folder
         $randName = generateRandomString(100);
         $name = $path . '/private/galerie/' . $randName . '.png';
         imagepng($dest, $name);
         // release ressources
         imagedestroy($dest);
         imagedestroy($src);