v2.5.2
Giriş yap

Jquery Çoklu fotoğraf yükleme hakkında

emmir2
747 defa görüntülendi ve 2 kişi tarafından değerlendirildi

Bu şekilde nası kayıt eder ve veriyi nası çekerim

Cevap yaz
Cevaplar (12)
qplot
1074 gün önce

php ornegını yaptım gerısı sende

https://www.verot.net/php_class_upload_download.htm

gereklı dosyayı dahıl et


<?php 
namespace Verot\Upload; 

include('src/class.upload.php');

?>
<!DOCTYPE html>
<html lang="tr">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	
<form action="" method="POST" enctype="multipart/form-data">
<p>Resimler:
<input type="file" name="gorsel[]" multiple />
<input type="submit" name="resimkayit" value="Gönder" />
</p>
</form>	
	
	
<?php
	


 
if((isset($_FILES['gorsel']))){
 
    $dosya_yolu = "img/";
 
    $files = array();
    foreach ($_FILES['gorsel'] as $k => $l) {
        foreach ($l as $i => $v) {
            if (!array_key_exists($i, $files))
                $files[$i] = array();
            $files[$i][$k] = $v;
        }
    }

     foreach ($files as $file) {

         $handle = new Upload($file);
 
        if ($handle->uploaded) {

// kucuk     
			$sifrele = rand(1234567,7654321);
			
          	$handle->file_new_name_body = $sifrele; 
			$handle->file_auto_rename = true;
            $handle->image_resize = true; 
			$handle->image_x = 900;  
			$handle->image_ratio_y = true;
            $handle->mime_check = true;  
            $handle->image_convert         = 'jpg';
            $handle->jpg_quality          = 100;
 			$handle->Process($dosya_yolu);  
            $buyuk = $handle->file_dst_name; // BUYUK HALI
  
 
  
			
          	$handle->file_new_name_body = $sifrele; 
			$handle->file_auto_rename = true;
            $handle->image_resize = true;
			$handle->image_ratio_crop      = 'C';
			$handle->image_x = 380;  
			$handle->image_y = 210;
            $handle->mime_check = true;  
            $handle->image_convert         = 'jpg';
            $handle->jpg_quality          = 75;
 			
 			$handle->Process($dosya_yolu);  
            $kucuk = $handle->file_dst_name; //KUCUK HALI 
 
            } else {
 
               //hata kodu
          
 
            }

 
            if ($handle->processed) {
 
             $kayit =$db->prepare("INSERT INTO foto_tablon(resim) VALUES(?)");
			 $kayit->execute([$buyuk]);
				
			echo '<img src="img/'.$buyuk.'">';	
				
  
        } else {
                echo $handle->error ;

        }
    }

 }	
	
?>	
	
	
	
</body>
</html>
emmir2
1070 gün önce

@qplot hocam bir konuda da daha yardımcı olursan sevinirim şimdi ürün düzenlede kaydettiğim fotoğrafı düzenleyebiliyorum ama ekle dediğimde ekleyemiyorum bunun için nası birşey yapabilirim
örnek ile gösterirsen yine harika olur

emmir2
1074 gün önce

Ellerine sağlık @qplot hocam

qplot
1074 gün önce

bekle halledeyım bır ornek

emmir2
1074 gün önce

Klasöre Resimler kayıt ediliyor ama veritabanına ekletemedim

<form method="post" action="" enctype="multipart/form-data">
<input type="file" name="resim[]"/>
<input type="file" name="resim[]"/>
<input type="file" name="resim[]"/>
<input type="file" name="resim[]"/>
<input type="submit" name="submit" value="Gönder" />
</form>

<?php

include 'verot.net.php';
 
$images = array();
foreach ($_FILES['resim'] as $k => $l) {
  foreach ($l as $i => $v) {
    if (!array_key_exists($i, $images))
      $images[$i] = array();
    $images[$i][$k] = $v;
  }
}
 
foreach ($images as $image){
 
    $cokluyukleme = new Upload($image);
    if ($cokluyukleme->uploaded) {
        $cokluyukleme->file_new_name_body = uniqid("deneme");
        $cokluyukleme->allowed = array('image/*');
        $cokluyukleme->Process("upload/");
        if ($cokluyukleme->processed) {
              echo 'ok';
        } else {
              echo $cokluyukleme->error;
        }
        $cokluyukleme-> Clean();
    } else {
        echo $cokluyukleme->error;
    }
}
 
?>

Veritabanı yapım

emmir2
1074 gün önce

Hocam bi türlü yapamadım :(

qplot
1075 gün önce

verot upload kullanmalısın sonra hack yeme

https://www.verot.net/php_class_upload.htm

http://www.erbilen.net/verot-net-upload-sinifi-kullanimi/

verot kodlarını sısteme dahıl et sonra bunu kullan

    // as it is multiple uploads, we will parse the $_FILES array to reorganize it into $files
    $files = array();
    foreach ($_FILES['gorsel'] as $k => $l) {
        foreach ($l as $i => $v) {
            if (!array_key_exists($i, $files))
                $files[$i] = array();
            $files[$i][$k] = $v;
        }
    }

    // now we can loop through $files, and feed each element to the class
    foreach ($files as $file) {

        // we instanciate the class for each element of $file
        $handle = new Upload($file);

        // then we check if the file has been uploaded properly
        // in its *temporary* location in the server (often, it is /tmp)
        if ($handle->uploaded) {

            // now, we start the upload 'process'. That is, to copy the uploaded file
            // from its temporary location to the wanted location
            // It could be something like $handle->process('/home/www/my_uploads/');
            $handle->process($dir_dest);

            // we check if everything went OK
            if ($handle->processed) {
                // everything was fine !
                echo '<p class="result">';
                echo '  <b>File uploaded with success</b><br />';
                echo '  File: <a href="'.$dir_pics.'/' . $handle->file_dst_name . '">' . $handle->file_dst_name . '</a>';
                echo '   (' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB)';
                echo '</p>';
            } else {
                // one error occured
                echo '<p class="result">';
                echo '  <b>File not uploaded to the wanted location</b><br />';
                echo '  Error: ' . $handle->error . '';
                echo '</p>';
            }

        } else {
            // if we're here, the upload file failed for some reasons
            // i.e. the server didn't receive the file
            echo '<p class="result">';
            echo '  <b>File not uploaded on the server</b><br />';
            echo '  Error: ' . $handle->error . '';
            echo '</p>';
        }

        $log .= $handle->log . '<br />';
    }
emmir2
1075 gün önce

Yokmu yardımcı olacak biri :D

emmir2
1086 gün önce

1 . veriden sonra hep array olarak yazdırıyor :(

<?php
<?php 
$baglan = "localhost";
$dbname = "resim";
$kullanici = "root";
$parola = "";

try {
	$db = new PDO("mysql:host=$baglan;dbname=$dbname;charset=utf8",$kullanici,$parola);
} catch (PDOException $e) {
	echo $e->getMessage();
}
?>


<form action="" method="POST" enctype="multipart/form-data">
<p>Resimler:
<input type="file" name="gorsel[]" />
<input type="file" name="gorsel[]" />
<input type="file" name="gorsel[]" />
<input type="submit" name="resimkayit" value="Gönder" />
</p>
</form>


<?php
if (isset($_POST['resimkayit'])) {
foreach ($_FILES["gorsel"]["error"] as $anahtar => $hata) {
    if ($hata == UPLOAD_ERR_OK) {
        $uploads_dir = 'data';
		@$tmp_name = $_FILES['gorsel'][ "tmp_name" ][$anahtar];
		$benzersizsayi4 = rand( 20000, 32000 );
		$uzanti         = '.jpg';
		$resimyol    = substr( $uploads_dir ) . "/" . $benzersizsayi4 . $uzanti .[$anahtar];

		@move_uploaded_file( $tmp_name, "$uploads_dir/$benzersizsayi4$uzanti");
    }
}
$kaydet=$db->prepare("INSERT INTO resim SET
		gorsel=:gorsel");
$insert=$kaydet->execute(array(
		'gorsel' => $resimyol
	));

if ($insert) {
		header("Location:index.php?durum=ok");
	} else {
		header("Location:index.php?durum=no");
	}
}
?>
firatogr
1086 gün önce
print_r($_POST['images']);
emmir2
1086 gün önce

Haaa diğer text kaydetme gibi anladım peki bu görselleri nası çekebiliriz fikriniz varmı hocam

firatogr
1086 gün önce

Tipi file olan inputların name değerlerini array olarak verebilirsin. Bu sistemde tüm dosyaların name değerlerini şöyle vermen gerekiyor: images[] (images örnek olarak istediğin name değerini verebilirsin ama sonunda köşeli parantez açıp kapatman gerekiyor bu sayede tüm dosyalara tek bir arrayden ulaşabilirsin).