function resimyukle($name) {
if(isset($_FILES[$name])){
$hata = $_FILES[$name]['error'];
if($hata != 0) {
} else {
$boyut = $_FILES[$name]['size'];
if($boyut > (1024*1024*3)){
echo 'Dosya 3MB den büyük olamaz.';
} else {
$tip = $_FILES[$name]['type'];
$isim = $_FILES[$name]['name'];
$uzanti = explode('.', $isim);
$uzanti = $uzanti[count($uzanti)-1];
if($uzanti != 'png' && $uzanti != 'jpeg' && $tip != 'image/jpeg' && $tip != 'image/png' ) {
echo 'Yanlızca JPG ve PNG uzantılı resimler yükleyebilirsiniz.';
} else {
$dosya = $_FILES[$name]['tmp_name'];
$random= rand(0,90).rand(0,90).rand(0,90).rand(0,90);
copy($dosya, 'assets/uploads/' .$random . ".".$uzanti);
$resimadi='assets/uploads/'.$random . ".".$uzanti;
}
}
}
}
return $resimadi;
Kullanım: $resim1= resimyukle(inputismi);
} Büyük resimleri küçültme yardım.
3
●342
- 08-07-2016, 05:27:57Resim upload ederken resmin genişlik yüksekliğini nasıl küçültürüm ?
- 08-07-2016, 13:01:19ImageMagick ya da GD iş görebilir.dursunkoca adlı üyeden alıntı: mesajı görüntüle
Örnek olarak;
function resize_image($file, $w, $h, $crop=FALSE) { list($width, $height) = getimagesize($file); $r = $width / $height; if ($crop) { if ($width > $height) { $width = ceil($width-($width*abs($r-$w/$h))); } else { $height = ceil($height-($height*abs($r-$w/$h))); } $newwidth = $w; $newheight = $h; } else { if ($w/$h > $r) { $newwidth = $h*$r; $newheight = $h; } else { $newheight = $w/$r; $newwidth = $w; } } $src = imagecreatefromjpeg($file); $dst = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); return $dst; }Fonksiyon kısaca böyle çalışır;
$img = resize_image(/path/to/some/image.jpg, 200, 200);
İlgili fonksiyonları koduna ekleyip son adımda yapabilirsin.
/path/to/some/image.jpg yerine $resimadi yaparak anlık yapabilirsin eğer çıkan sonucu doğru gördüysem öyle olur yani. 200 değerlerini kendine göre düzenlersin. - 08-07-2016, 14:40:15
- 08-07-2016, 17:54:41Rica ederim hocam. Çözüme ulaştıysa R10+ verirseniz çok sevinirim.dursunkoca adlı üyeden alıntı: mesajı görüntüle