Üye Bilgileri
Nick:bytokca
İsim:Halil Tokca
Web sayfası:
Cinsiyet:Erkek
İmza:
Konu sayısı:1
Cevap sayısı:0
Kaç günlük üye1
Son yazdığı Php kodları mesajları
Selamun aleyküm. Arkadaşlar bir türlü çoklu resim yüklemeyi yapamadım. Yardımlarınızı bekliyorum. Kodları paylaşıyorum. Bu kodlar üzerinde yapmak istiyorum. Çok güzel sınıflar var ama yinede ben bu kodlar üzerinde çalışmak istiyorum.
Resim Yükleme kodları..
<?php	error_reporting(E_ALL & ~E_NOTICE);	ini_set('error_reporting', E_ALL & ~E_NOTICE);	if (phpversion() > "5.2.6") { $HTTP_POST_FILES = &$_FILES;}	define("MAX_SIZE",0);	define("DESTINATION_FOLDER", "../upload");	define("hata_yok", "#");	define("hata_var", "resim_hata.php");	$_uzanti_kabul_ = "png,PNG,JPG,JPEG,jpg,jpeg,gif,GIF";	if(strlen($_uzanti_kabul_) > 0){	$_uzanti_kabul_ = @explode(",",$_uzanti_kabul_);	} else { $_uzanti_kabul_ = array();}	$_dosya_ = $HTTP_POST_FILES['resim'];	if(is_uploaded_file($_dosya_['tmp_name']) && $HTTP_POST_FILES['resim']['error'] == 0){	$hatalar = "Hata";	$dosya =$_dosya_['name'];	$uzanti = strtolower(strrchr($dosya,'.'));	$_resim_adi_ = substr(md5(rand(0,9999999999)),-10)."-HT".$uzanti;	$_type_ = $_dosya_['type'];	$_tmp_resim_adi_ = $_dosya_['tmp_name'];	$_boyut_ = $_dosya_['size'];	if($_boyut_ > MAX_SIZE && MAX_SIZE > 0){ $hatalar = "Dosya çok ağır"; }	$_ekstra_ = explode(".", $_resim_adi_);	$_ekstra_ = strtolower($_ekstra_[count($_ekstra_)-1]);	if(!in_array($_ekstra_, $_uzanti_kabul_) && count($_uzanti_kabul_) > 0){ $hatalar = "Uzantı geçerli değil"; }	if(!is_dir(DESTINATION_FOLDER) && is_writeable(DESTINATION_FOLDER)){ $hatalar = "Hedef klasörü geçerli değil"; }	if(empty($hatalar)){	if(@copy($_tmp_resim_adi_,DESTINATION_FOLDER . "/" . $_resim_adi_)){	header("Location: " . hata_yok);	} else { header("Location: " . hata_var); }	} else { header("Location: " . hata_var); }	}
?>
Mysql Kodları...
<?php
$db_host = "localhost";
$db_baglan = "resimler";
$db_isim = "root";
$db_sifre = "";
$baglan = mysql_pconnect($db_host, $db_isim, $db_sifre) or trigger_error(mysql_error(),E_USER_ERROR);
if (!function_exists("ck")) {	function ck($deger, $tur, $tanimlideger = "", $tanimsizdeger = "")	{	if (PHP_VERSION < 6) {	$deger = get_magic_quotes_gpc() ? stripslashes($deger) : $deger;	}	$deger = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($deger) : mysql_escape_string($deger);	switch ($tur) {	case "text": $deger = ($deger != "") ? "'" . $deger . "'" : "NULL"; break;	case "long":	case "int": $deger = ($deger != "") ? intval($deger) : "NULL"; break;	case "double": $deger = ($deger != "") ? doubleval($deger) : "NULL"; break;	case "date": $deger = ($deger != "") ? "'" . $deger . "'" : "NULL"; break;	case "defined": $deger = ($deger != "") ? $tanimlideger : $tanimsizdeger; break;	}	return $deger;	}	}	$kaydett = $_SERVER['PHP_SELF'];	if (isset($_SERVER['QUERY_STRING'])) {	$kaydett .= "?" . htmlentities($_SERVER['QUERY_STRING']);	}	if ((isset($_POST["ekle"])) && ($_POST["ekle"] == "resim")) {	$Sql_Bag = sprintf("INSERT INTO resimler (urun_kat, resim_adi, resim) VALUES (%s, %s, %s)",	ck($_POST['urun_kat'], "int"),	ck($_POST['resim_adi'], "text"),	ck($_resim_adi_, "text"));	mysql_select_db($db_baglan, $baglan);	$result = mysql_query($Sql_Bag, $baglan) or die(mysql_error());	$yonlen = "resimler.php";	if (isset($_SERVER['QUERY_STRING'])) {	$yonlen .= (strpos($yonlen, '?')) ? "&" : "?";	$yonlen .= $_SERVER['QUERY_STRING'];	}	header(sprintf("Location: %s", $yonlen));	}
Js Kodları...
<script>	$(document).ready(function(){	function ekle(){	$("#yuklekutu").append('<input type="file" name="resim[]" id="resim[]" /></span>');	};	$("#form").bind("submit", function(){	$("#sonuclar").empty();	$(this).attr("target","gelenBilgi");	$("<img />").attr("src","rsm/bekle.gif").appendTo($("#sonuclar"));	$("#gelenBilgi").bind("load", function(){	var deger = $("#gelenBilgi").contents().find("body").html();	$("#sonuclar").html(deger);	});	});	$('#bekleyin').hide();	});	</script>
Resim Yükleme Kodları...
<form name="resim" id="resim" action="<?php echo $kaydett; ?>" method="POST" enctype="multipart/form-data" class="form">	<div class="siralan">	<label for="resim">Resim Ekle :</label>	<input type="file" name="resim[]" id="resim[]" style="width: 300px;" multiple>	<a href="javascript:void(0);" class="menu" onclick="ekle()">+Yeni Resim Ekle</a>	</div>	<div class="siralan" id="yuklekutu"></div>	<div class="siralan">	<label>Kategoriyi Seçin:</label>	<select name="urun_kat" id="urun_kat" class="select validate[required]" style="width: 300px;">	<?php do { ?>	<option value="<?php echo $row_urun['urun_id']; ?>" ><?php echo $row_urun['urun_adi_tr']?></option>	<?php } while ($row_urun = mysql_fetch_assoc($urun)); mysql_free_result($urun); ?>	</select>	</div>	<div class="siralan">	<label>Resim Adı :</label><input name="res_id" type="hidden">	<input name="resim_adi" type="text" id="resim_adi" style="width: 300px;"/>	</div>	<div class="siralan"><input type="submit" class="submit" value="Ekle" /></div>	<input type="hidden" name="ekle" value="resim"> </form>
Yardımlarınızı esirgemeyin.
Zaman2013-09-19 12:33:36
Php Çoklu resim upload yardım

phpkodlari.com © 2009 Herkes Php öğrenecek
Web tasarım ve eğitim kaynağınız.