Results 1 to 1 of 1
Thread: .
Hybrid View
-
8th December 2014 23:18 #1
.
a. , . ? . 100 51 94.
add_album
PHP Code:define("IMAGES_BIG_DIR", "../images/Big_images/");
define("IMAGES_SMALL_DIR", "../images/Small_images/");
define("IMAGE_HEIGHT", 180);
define("IMAGE_WIDTH", 210);
$allowed_type = array(
'image/jpeg',
'image/jpg',
'image/JPG',
'image/JPEG',
'image/pjpeg',
'image/x-png',
'image/png',
);
$allowed_ext = array('jpg', 'png', 'JPG', 'jpeg', 'JPEG');
if ( !empty($_FILES) ) {
//echo "<pre>";
//print_r($_POST);
//print_r($_FILES);
$number_of_images = isset($_FILES['images']['name']) ? count($_FILES['images']['name']) : 0;
if ( $number_of_images > 0 ) {
foreach ( $_FILES['images']['name'] as $nImagekey => $sImagaName ) {
if ( isset($_FILES['images']['error'][$nImagekey]) && $_FILES['images']['error'][$nImagekey] == UPLOAD_ERR_OK ) {
$extension = pathinfo($sImagaName, PATHINFO_EXTENSION);
if ( !in_array($_FILES['images']['type'][$nImagekey], $allowed_type) ) {
echo " !";
exit;
} else if ( !in_array($extension, $allowed_ext) ) {
echo " !";
exit;
}
$fn = sprintf(sha1_file($_FILES['images']['tmp_name'][$nImagekey]).'.%s', $extension);
$file_name = sprintf(IMAGES_BIG_DIR.'%s', $fn);
$file_name_sm = sprintf(IMAGES_SMALL_DIR.'%s', $fn);
$original_images_array[] = $file_name;
$small_images_array[] = $file_name_sm;
if ( !copy($_FILES['images']['tmp_name'][$nImagekey], $file_name) ) {
echo " .";
exit;
}
if ( strtolower($extension) == "jpg" ) {
$raw_img = imagecreatefromjpeg($file_name);
} else if ( strtolower($extension) == "png" ){
$raw_img = imagecreatefrompng($file_name);
}
if ( $raw_img ) {
$raw_x = imageSX($raw_img);
$raw_y = imageSY($raw_img);
if ($raw_x > $raw_y) {
$thumb_w = IMAGE_WIDTH;
$thumb_h = $raw_y * (IMAGE_HEIGHT / $raw_x);
} else if ($raw_x < $raw_y) {
$thumb_w = $raw_x * (IMAGE_HEIGHT / $raw_y);
$thumb_h = IMAGE_HEIGHT;
} else if ($raw_x == $raw_y) {
$thumb_w = IMAGE_WIDTH;
$thumb_h = IMAGE_HEIGHT;
}
$thumb = ImageCreateTrueColor($thumb_w, $thumb_h);
imagecopyresampled($thumb, $raw_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $raw_x, $raw_y);
if ( strtolower($extension) == "jpg" ) {
imagejpeg($thumb, $file_name_sm);
} else if ( strtolower($extension) == "png" ){
imagepng($thumb, $file_name_sm);
}
imagedestroy($thumb);
imagedestroy($raw_img);
}
}
}
}
} else if ( !empty($_POST) ) {
echo " . ";
exit;
}
$original_images_string = implode("|", $original_images_array);
$small_images_string = implode("|", $small_images_array);




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in