Exemple #1
0
    // On this example, obtain safe unique name from its binary data.
    define("finalname", sha1_file($_FILES['upfile']['tmp_name']));
    if (!move_uploaded_file($_FILES['upfile']['tmp_name'], sprintf($uploadpath, finalname, $ext))) {
        do_return(null, 'Failed to move uploaded file.');
    }
    $resizer = new SimpleImage();
    /*
    $resizer->load(    sprintf('/home/m/meworyru/strikeball/msk-aspid/public_html/album/%s.%s',
        finalname,
        $ext
    ));
    $resizer->resizeToWidth(200);
    $resizer->save(sprintf('/home/m/meworyru/strikeball/msk-aspid/public_html/album/thumbs/%s.%s',
        finalname,
        $ext
    ));
    */
    $resizer->resize_crop_image($sizeX, $sizeY, sprintf($uploadpath, finalname, $ext), sprintf($resizepath, finalname, $ext));
    do_return(sprintf($resizepath, finalname, $ext), null);
} catch (RuntimeException $e) {
    echo $e->getMessage();
}
function do_return($msg, $err)
{
    echo '
        {
         "message" : "' . $msg . '",
         "error" : "' . $err . '"
        }';
    exit;
}