$kontrol = explode('.',$_FILES["resim"]["name"]);
$kontrol = end($kontrol);
if($kontrol == "jpeg" | $kontrol == "jpg" | $kontrol == "png" )
{
$filename=$_FILES['resim']['tmp_name'];
$dosyaadi = substr(md5($_FILES['resim']['name'].time().rand(0, 1000)), 5, 10).".".$kontrol;
$destination="../images/".$dosyaadi;
move_uploaded_file($filename,$destination);
}
$insertSQL = sprintf("INSERT INTO slider (resim, resimyazi, resimlink) VALUES (%s, %s, %s)",
GetSQLValueString($dosyaadi, "text"),
GetSQLValueString($_POST['resimyazi'], "text"),
GetSQLValueString($_POST['resimlink'], "text"));fikri olan arkadaş yardım ederse yada daha farklı sınıf kullanan varsa örnekle anlatırsa sevınırım
move uploaded file resize image Özelliği Ekleme
11
●2.807
- 05-03-2014, 16:41:29merhaba arkadaslar Dosya yüklerken move_uploaded kullanıyorum ama şöylede bi sorunum var acaba bu resımler X , Y gibi özelliği tam olarak nasıl eklicez yani Boyutlandırma olayı Şuanda kullandıgım kod :
- 05-03-2014, 17:27:38Şuanda hocam 2 attığınızı kendı kodlarıma entegre edıp yüklemeyi deniyeceğim kodları inceliyorum suanda sizede bilgi verecemcaxe adlı üyeden alıntı: mesajı görüntüle
--R10.NET; Flood Engellendi -->-> Yeni yazılan mesaj 17:27:38 -->-> Daha önceki mesaj 17:10:09 --
@caxe Hocam Resim yükleme işlemi oldu ama veritabanına bu resmı kayıt ettıremiyorum sorun burda oluyor diğer türlü sorun yok - 05-03-2014, 17:31:11Kimlik doğrulama veya yönetimden onay bekliyor.@TuncerMehmet; şu şekilde çözebiliriz.
sınıf dosyamız;
<?php /** * @kaynak: http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/ */ class SimpleImage { var $image; var $image_type; function load($filename) { $image_info = getimagesize($filename); $this->image_type = $image_info[2]; if($this->image_type == IMAGETYPE_JPEG) { $this->image = imagecreatefromjpeg($filename); } elseif($this->image_type == IMAGETYPE_GIF) { $this->image = imagecreatefromgif($filename); } elseif($this->image_type == IMAGETYPE_PNG) { $this->image = imagecreatefrompng($filename); } } function save($filename, $image_type = IMAGETYPE_JPEG, $compression = 75, $permissions = null) { if($image_type == IMAGETYPE_JPEG) { imagejpeg($this->image, $filename, $compression); } elseif($image_type == IMAGETYPE_GIF) { imagegif($this->image, $filename); } elseif( $image_type == IMAGETYPE_PNG ) { imagepng($this->image, $filename); } if($permissions != null) { chmod($filename, $permissions); } } function output($image_type = IMAGETYPE_JPEG) { if($image_type == IMAGETYPE_JPEG) { imagejpeg($this->image); } else if($image_type == IMAGETYPE_GIF) { imagegif($this->image); } else if($image_type == IMAGETYPE_PNG) { imagepng($this->image); } } function getWidth() { return imagesx($this->image); } function getHeight() { return imagesy($this->image); } function resizeToHeight($height) { $ratio = $height / $this->getHeight(); $width = $this->getWidth() * $ratio; $this->resize($width, $height); } function resizeToWidth($width) { $ratio = $width / $this->getWidth(); $height = $this->getheight() * $ratio; $this->resize($width, $height); } function scale($scale) { $width = $this->getWidth() * $scale / 100; $height = $this->getheight() * $scale / 100; $this->resize($width, $height); } function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight()); $this->image = $new_image; } }Dosya yükleme esnasında kullanımı;
<?php # Üst kısımda verdiğim sınıf dosyasını dahil edelim. require("simple-image.php"); if(isset($_FILES["resim"])) { $dosya_tipi = explode(".", $_FILES["resim"]["name"]); $dosya_tipi = end($dosya_tipi); if($dosya_tipi == "jpg" || $dosya_tipi == "jpeg" || $dosya_tipi == "png") { $dosya_gecici_yolu = $_FILES["resim"]["tmp_name"]; $dosya_ismi = sprintf("%s.%s", substr(md5($_FILES["resim"]["name"].time().rand(0, 1000)), 5, 10), $dosya_tipi); $dosya_yolu = $dosya_ismi; move_uploaded_file($dosya_gecici_yolu, $dosya_yolu); # Yeniden boyutlandırma işlemi $resim = new SimpleImage(); $resim->load($dosya_yolu); if($resim->getHeight() > 600) { $resim->resizeToHeight(600); } if($resim->getWidth() > 800) { $resim->resizeToWidth(800); } if($resim->image_type == IMAGETYPE_JPEG) { $resim->save($dosya_yolu, $resim->image_type, IMAGETYPE_JPEG); } if($resim->image_type == IMAGETYPE_PNG) { $resim->save($dosya_yolu, $resim->image_type, IMAGETYPE_PNG); } echo "İşlem Başarılı!"; } } ?><!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> </head> <body> <form method="post" enctype="multipart/form-data"> <input type="file" name="resim" /> <button type="submit">Yükle</button> </form> </body> </html> - 05-03-2014, 17:44:57saintx adlı üyeden alıntı: mesajı görüntüle
hocam sizin kodlarda resim yükleme esnası olan bölümde
$resim = new SimpleImage(); hata veriyor ve dosya yolu değişkeninde yol olarak biyerde yok yolu kendım bilirttigim halde aynı hatayı aliyorum require ve include yaparakta denedim o class i olmadi - 05-03-2014, 18:05:21saintx adlı üyeden alıntı: mesajı görüntüle
sisteme entegre ettim dosya yolu kısmında söyle birşey yaptım cunku istedigim yere yükletcektım hocam : $dosya_yolu ="../images/".$dosya_ismi;
bunu yapınca verıtabanına normal adıyla kaydettı ve resmı yüklemedi acaba bunu nasıl düzeltcez acaba - 05-03-2014, 18:07:12@TuncerMehmet; mysql_query ile sorguyu gönderdikten sonra
print_r(array(mysql_errno(), mysql_error()));
betiğini ekleyip çıktısını konuya ekleyebilir misin?