Yazan:drekon
if(move_uploaded_file($_FILES["res_yolu"]['tmp_name'], $target_path))
{
// INSERT INTO komutunu buraya koy.
}
Çok teşekkürler kod çalıştı şimdi tek sorun dosya seçmeme rağmen dosya upload ediliyor fakat dosya yolunda upload edilen dosyanın ismi yazılmıyor. sayfayı yenilemeden 1 dosya daha seçip yüklediğimde kod çalışıyor upload yoluda ekleniyor. Yani 1 tane boş satır eklenmiş oluyor bunu nasıl çözeceğimi bitürlü bulamadım kaç haftadır. Şimdi farkettim dosya yolu hep 1 dosya geriden geliyor. ör a.jpg yüklemeye çalıştım upload tamam fakat dosyayolu yok b.jpg seçip attığımda dosya yoluna a.jpg çıkıyor.
Zaman
2013-07-14 12:00:38Php php Merhaba arkadaşlar şimdi ben kendime kişisel bi site yapıyorum. aşağıdaki kod ile siteme belirttiğim yere resim upload ediyorum ve ismi ile yolunu mysql e atıyorum. 2 Çeşit problem yaşıyorum. 1- İlk upload ettiğimde dosya gidiyor mysql yolu kaydetmiyor. tekrar dosyayı seçip attığımda atıyor fakat arada boş kayıt oluşmuş oluyor. 2. sorum ise resim upload edilemediğinde mysql işlemini iptal etmem lazm bunu nasıl yaparım aceba? kodlar aşağıda...
Kod:
<?php require_once('../Connections/deneme.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
$insertSQL = sprintf("INSERT INTO tb_resimler (res_yolu, res_ad) VALUES (%s, %s)",
GetSQLValueString($_POST['res_yolu2'], "text"),
GetSQLValueString($_POST['res_ad'], "text"));
mysql_select_db($database_deneme, $deneme);
$Result1 = mysql_query($insertSQL, $deneme) or die(mysql_error());
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/deneme_admin.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Başlıksız Belge</title>
<!-- InstanceEndEditable -->
<link href="css/mycss.css" rel="stylesheet nofollow" type="text/css" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
<body>
<table width="960" border="1" cellspacing="0">
<tr>
<td colspan="2" align="center" bgcolor="#FF9900"><h3><strong>Graficity.net Admin Panel</strong></h3></td>
</tr>
<tr>
<td width="18%" align="left" bgcolor="#99CC00"><h3>İşlem</h3></td>
<td width="82%" align="left" bgcolor="#99CC00"><h3>Açıklama</h3></td>
</tr>
<tr>
<td align="left" valign="top"><ul>
<li><a href="index.php">Anasayfa</a></li>
<li><a href="tas_guncel.php"></a><a href="tas_ekle.php">Tasarım Ekle</a></li>
<li><a href="tas_sil.php"></a><a href="tas_listele.php">Tasarım Listele</a></li>
<li><a href="res_ekle.php">Resim Ekle</a></li>
<li>Resim Listele</li>
</ul></td>
<td align="left" valign="top"><!-- InstanceBeginEditable name="bolge" -->
<form name="form" enctype="multipart/form-data" action="<?php echo $editFormAction; ?>" method="POST">
<table width="100%">
<tr>
<td width="22%"><h2>Resim Ekle</h2></td>
<td width="78%"> </td>
</tr>
<tr>
<td>Resim Adı:</td>
<td><label for="res_ad"></label>
<input type="text" name="res_ad" id="res_ad" /></td>
</tr>
<tr>
<td>
Yüklenecek Dosyayı Seçin:
<br />
</td>
<td><label for="res_yolu"></label>
<input type="file" name="res_yolu" id="res_yolu" /></td>
</tr>
<?php
error_reporting(E_ALL ^ E_NOTICE);
$target_path = "../images/uploaded/";
$target = "images/uploaded/";
$target = $target . basename( $_FILES['res_yolu']['name']);
$target_path = $target_path . basename( $_FILES['res_yolu']['name']);
if(move_uploaded_file($_FILES["res_yolu"]['tmp_name'], $target_path)) {
echo basename( $_FILES["res_yolu"]['name']).
" Dosyası Başarıyla Yüklendi";
} else{
echo "Dosya Yüklenirken Bir Hata Oluştu!";
}
?>
<tr>
<td> </td>
<td><input type="submit" value="Dosyayı Yükle" /></td>
</tr>
<tr>
<td> </td>
<input type="hidden" name="res_yolu2" value="<?php echo $target; ?>"/>
<td> </td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form" />
</form>
<!-- InstanceEndEditable --></td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
Zaman
2013-07-10 18:58:37Php Php Kodum İçin Yardımınız Gerekli