Php+MYSQL kullanarak veritabanına çoklu olarak resim yüklüyorum. Kullandığım Class ile gelen resimlerin thumbnail ini oluşturup veritabanına yazıyorum class aşağıda.
Benim sorunum yüklenen resimlerin yolunu farklı id ile belirttiğim tabloya değil de GET ile çektiğim id deki row a yazmak yani tek satıra.
Diyelim ki 900 numaralı id de resim1 resim 2 resim 3 resim4 resim5 resim6..... diye basliklarim var yüklenen resim yollarını buraya nasıl yazdırabilirim.
Değerli yardımlarınız için şimdiden teşekkürler.
<?php if(session_is_registered("uye")){
$hasanurunno = $_GET["hasanurunno"];
$uyeyibul = $_SESSION["uye"];
if(isset($_POST['btn_upload']))
{
function deal_image($i) {
$prodcat = $_POST['pcate'];
$prodname = $_POST['pname'];
$prodec = $_POST['pdesc'];
$prodcode = $_POST['pcode'];
$prodprice = $_POST['pprice'];
$prodffers = $_POST['poffers'];
$pDate = $_POST['pdate'];
$hasanurunno = $_GET["hasanurunno"];
$uyeyibul = $_SESSION["uye"];
$filetmp = $_FILES["file_img"]["tmp_name"][$i];
$filename = $_FILES["file_img"]["name"][$i];
$filetype = $_FILES["file_img"]["type"][$i];
$filesize = $_FILES["file_img"]["size"][$i];
$fileinfo = getimagesize($filetmp);
$filewidth = $fileinfo[0];
$fileheight = $fileinfo[1];
// GETS FILE EXTENSION
$fileextension = pathinfo($filename, PATHINFO_EXTENSION);
$microtime = preg_replace('/[^A-Za-z0-9]/', "", microtime());
$filepath = "resim/hasan/".$microtime.".".$fileextension;
$filepath_thumb = "resim/hasan/thumbs/".$microtime.".".$fileextension;
move_uploaded_file($filetmp,$filepath);
if($filetype == "image/jpeg")
{
$imagecreate = "imagecreatefromjpeg";
$imageformat = "imagejpeg";
}
if($filetype == "image/png")
{
$imagecreate = "imagecreatefrompng";
$imageformat = "imagepng";
}
if($filetype == "image/gif")
{
$imagecreate= "imagecreatefromgif";
$imageformat = "imagegif";
}
$new_height = "75"; /* resmin yeni genişliği buluyoruz */
$new_width = round(($filewidth * $new_height) / $fileheight);
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = $imagecreate($filepath); //photo folder
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $filewidth, $fileheight);
$imageformat($image_p, $filepath_thumb);//thumb folder
$sql = "INSERT INTO `files` (name,hasanurunno,title,kimsatiyor) VALUES ('$filepath','$hasanurunno','$filepath_thumb','$uyeyibul')";
$result = mysql_query($sql);
}
foreach($_FILES["file_img"]['name'] as $id => $file) {deal_image($id);}
}
header("Location:?sayfaid=456465&hasanurunno=$hasanurunno");
}else{ echo "<script language=javascript>top.location.href='index.php';</script>"; } ?>