• 05-03-2014, 16:41:29
    #1
    merhaba 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 :

    $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
  • 05-03-2014, 16:54:17
    #2
    Üyeliği durduruldu
    @TuncerMehmet; Merhaba hocam şu fonksiyonu bir inceleyebilirmisiniz?


    Bide aradıgınız özellikde şole bir kaynak buldum demo suda burdadır wallpaper upload ettim resmi kuçulttu
  • 05-03-2014, 17:27:38
    #3
    caxe adlı üyeden alıntı: mesajı görüntüle
    @TuncerMehmet; Merhaba hocam şu fonksiyonu bir inceleyebilirmisiniz?


    Bide aradıgınız özellikde şole bir kaynak buldum demo suda burdadır wallpaper upload ettim resmi kuçulttu
    Şuanda hocam 2 attığınızı kendı kodlarıma entegre edıp yüklemeyi deniyeceğim kodları inceliyorum suanda sizede bilgi verecem

    --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:11
    #4
    Kimlik 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:57
    #5
    saintx adlı üyeden alıntı: mesajı görüntüle
    @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>


    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, 17:48:29
    #6
    @TuncerMehmet; şu bağlantıdan örneği indirip deneyebilir misin?
  • 05-03-2014, 18:05:21
    #7
    saintx adlı üyeden alıntı: mesajı görüntüle
    @TuncerMehmet; şu bağlantıdan örneği indirip deneyebilir misin?

    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
    #8
    @TuncerMehmet; mysql_query ile sorguyu gönderdikten sonra
    print_r(array(mysql_errno(), mysql_error()));
    betiğini ekleyip çıktısını konuya ekleyebilir misin?
  • 05-03-2014, 18:09:37
    #9
    Buyurun hocam resim;