çoklu resim upload sorunu.
Arkadaşlar lutfen yardım edin. Aşağıdaki kodlar ile resimleri yuklemek istiyorum. Resimlerin yolu veritabanına kaydedeliyor ancak dosyaya taşınmıyor.
Günlerdir ugrasıorum kafayı yemek üzereyim....
<?php require_once('Connections/ok_kisisel.php'); ?>
<?php
// ---------------------------------------------
// Pure PHP Upload version 1.1
// -------------------------------------------
if (phpversion() > "4.0.6") {
$HTTP_POST_FILES = &$_FILES;
}
define("MAX_SIZE",300000);
define("DESTINATION_FOLDER", "upload/");
define("no_error", "");
define("yes_error", "");
$_accepted_extensions_ = "";
if(strlen($_accepted_extensions_) > 0){
$_accepted_extensions_ = @explode(",",$_accepted_extensions_);
} else {
$_accepted_extensions_ = array();
}
/* modify */
if(!empty($HTTP_POST_FILES['MM_update'])){
if(move_uploaded_file($HTTP_POST_FILES['MM_update']['tmp_name']) && $HTTP_POST_FILES['MM_update']['error'] == 0){
$_file_ = $HTTP_POST_FILES['MM_update'];
$errStr = "";
$_name_ = $_file_['name'];
$_type_ = $_file_['type'];
$_tmp_name_ = $_file_['tmp_name'];
$_size_ = $_file_['size'];
if($_size_ > MAX_SIZE && MAX_SIZE > 0){
$errStr = "File troppo pesante";
}
$_ext_ = explode(".", $_name_);
$_ext_ = strtolower($_ext_[count($_ext_)-1]);
if(!in_array($_ext_, $_accepted_extensions_) && count($_accepted_extensions_) > 0){
$errStr = "Estensione non valida";
}
if(!is_dir(DESTINATION_FOLDER) && is_writeable(DESTINATION_FOLDER)){
$errStr = "Cartella di destinazione non valida";
}
if(empty($errStr)){
if(@copy($_tmp_name_,DESTINATION_FOLDER . "/" . $_name_)){
header("Location: " . no_error);
} else {
header("Location: " . yes_error);
}
} else {
header("Location: " . yes_error);
}
}
}
?>
<?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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE uyesin SET ad=%s, soyad=%s, mail=%s, tel=%s, sifre=%s, kullanici_adi=%s, resim=%s, resim1=%s, resim2=%s, resim3=%s WHERE id=%s",
GetSQLValueString($_POST['ad'], "text"),
GetSQLValueString($_POST['soyad'], "text"),
GetSQLValueString($_POST['mail'], "text"),
GetSQLValueString($_POST['tel'], "text"),
GetSQLValueString($_POST['sifre'], "text"),
GetSQLValueString($_POST['kullanici_adi'], "text"),
GetSQLValueString($_POST['resim'], "text"),
GetSQLValueString($_POST['resim1'], "text"),
GetSQLValueString($_POST['resim2'], "text"),
GetSQLValueString($_POST['resim3'], "text"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_ok_kisisel, $ok_kisisel);
$Result1 = mysql_query($updateSQL, $ok_kisisel) or die(mysql_error());
}
mysql_select_db($database_ok_kisisel, $ok_kisisel);
$query_uye = "SELECT * FROM uyesin";
$uye = mysql_query($query_uye, $ok_kisisel) or die(mysql_error());
$row_uye = mysql_fetch_assoc($uye);
$totalRows_uye = mysql_num_rows($uye);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Ad:</td>
<td><input type="text" name="ad" value="<?php echo htmlentities($row_uye['ad'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Soyad:</td>
<td><input type="text" name="soyad" value="<?php echo htmlentities($row_uye['soyad'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Mail:</td>
<td><input type="text" name="mail" value="<?php echo htmlentities($row_uye['mail'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Tel:</td>
<td><input type="text" name="tel" value="<?php echo htmlentities($row_uye['tel'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Sifre:</td>
<td><input type="text" name="sifre" value="<?php echo htmlentities($row_uye['sifre'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Kullanici_adi:</td>
<td><input type="text" name="kullanici_adi" value="<?php echo htmlentities($row_uye['kullanici_adi'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Resim:</td>
<td><input type="file" name="resim" value="<?php echo htmlentities($row_uye['resim'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Resim1:</td>
<td><input type="file" name="resim1" value="<?php echo htmlentities($row_uye['resim1'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Resim2:</td>
<td><input type="file" name="resim2" value="<?php echo htmlentities($row_uye['resim2'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Resim3:</td>
<td><input type="file" name="resim3" value="<?php echo htmlentities($row_uye['resim3'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Update record" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="id" value="<?php echo $row_uye['id']; ?>" />
</form>
<p> </p>
<p> </p>
</body>
</html>
<?php
mysql_free_result($uye);
?>
<?php
// ---------------------------------------------
// Pure PHP Upload version 1.1
// -------------------------------------------
if (phpversion() > "4.0.6") {
$HTTP_POST_FILES = &$_FILES;
}
define("MAX_SIZE",300000);
define("DESTINATION_FOLDER", "upload/");
define("no_error", "");
define("yes_error", "");
$_accepted_extensions_ = "";
if(strlen($_accepted_extensions_) > 0){
$_accepted_extensions_ = @explode(",",$_accepted_extensions_);
} else {
$_accepted_extensions_ = array();
}
/* modify */
if(!empty($HTTP_POST_FILES['MM_update'])){
if(move_uploaded_file($HTTP_POST_FILES['MM_update']['tmp_name']) && $HTTP_POST_FILES['MM_update']['error'] == 0){
$_file_ = $HTTP_POST_FILES['MM_update'];
$errStr = "";
$_name_ = $_file_['name'];
$_type_ = $_file_['type'];
$_tmp_name_ = $_file_['tmp_name'];
$_size_ = $_file_['size'];
if($_size_ > MAX_SIZE && MAX_SIZE > 0){
$errStr = "File troppo pesante";
}
$_ext_ = explode(".", $_name_);
$_ext_ = strtolower($_ext_[count($_ext_)-1]);
if(!in_array($_ext_, $_accepted_extensions_) && count($_accepted_extensions_) > 0){
$errStr = "Estensione non valida";
}
if(!is_dir(DESTINATION_FOLDER) && is_writeable(DESTINATION_FOLDER)){
$errStr = "Cartella di destinazione non valida";
}
if(empty($errStr)){
if(@copy($_tmp_name_,DESTINATION_FOLDER . "/" . $_name_)){
header("Location: " . no_error);
} else {
header("Location: " . yes_error);
}
} else {
header("Location: " . yes_error);
}
}
}
?>
<?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_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE uyesin SET ad=%s, soyad=%s, mail=%s, tel=%s, sifre=%s, kullanici_adi=%s, resim=%s, resim1=%s, resim2=%s, resim3=%s WHERE id=%s",
GetSQLValueString($_POST['ad'], "text"),
GetSQLValueString($_POST['soyad'], "text"),
GetSQLValueString($_POST['mail'], "text"),
GetSQLValueString($_POST['tel'], "text"),
GetSQLValueString($_POST['sifre'], "text"),
GetSQLValueString($_POST['kullanici_adi'], "text"),
GetSQLValueString($_POST['resim'], "text"),
GetSQLValueString($_POST['resim1'], "text"),
GetSQLValueString($_POST['resim2'], "text"),
GetSQLValueString($_POST['resim3'], "text"),
GetSQLValueString($_POST['id'], "int"));
mysql_select_db($database_ok_kisisel, $ok_kisisel);
$Result1 = mysql_query($updateSQL, $ok_kisisel) or die(mysql_error());
}
mysql_select_db($database_ok_kisisel, $ok_kisisel);
$query_uye = "SELECT * FROM uyesin";
$uye = mysql_query($query_uye, $ok_kisisel) or die(mysql_error());
$row_uye = mysql_fetch_assoc($uye);
$totalRows_uye = mysql_num_rows($uye);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Ad:</td>
<td><input type="text" name="ad" value="<?php echo htmlentities($row_uye['ad'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Soyad:</td>
<td><input type="text" name="soyad" value="<?php echo htmlentities($row_uye['soyad'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Mail:</td>
<td><input type="text" name="mail" value="<?php echo htmlentities($row_uye['mail'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Tel:</td>
<td><input type="text" name="tel" value="<?php echo htmlentities($row_uye['tel'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Sifre:</td>
<td><input type="text" name="sifre" value="<?php echo htmlentities($row_uye['sifre'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Kullanici_adi:</td>
<td><input type="text" name="kullanici_adi" value="<?php echo htmlentities($row_uye['kullanici_adi'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Resim:</td>
<td><input type="file" name="resim" value="<?php echo htmlentities($row_uye['resim'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Resim1:</td>
<td><input type="file" name="resim1" value="<?php echo htmlentities($row_uye['resim1'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Resim2:</td>
<td><input type="file" name="resim2" value="<?php echo htmlentities($row_uye['resim2'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Resim3:</td>
<td><input type="file" name="resim3" value="<?php echo htmlentities($row_uye['resim3'], ENT_COMPAT, 'utf-8'); ?>" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Update record" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="id" value="<?php echo $row_uye['id']; ?>" />
</form>
<p> </p>
<p> </p>
</body>
</html>
<?php
mysql_free_result($uye);
?>
2012-04-08 12:48:12
Php
arada /*modify*/ yazdığına göre o bölümde değişiklik yapılmasını önermişler.
şu fonksiyonda da iki parametre olması gerekiyor.
move_uploaded_file($HTTP_POST_FILES['MM_update']['tmp_name'])
seçili bölüm tek değişkendir. virgül atarak hedef dosya seçilmesi gerekiyor.
şöyle yap:
move_uploaded_file($HTTP_POST_FILES['MM_update']['tmp_name'] , $hedefdosya)
Her programcı birgün Php yi tadacaktır
2012-04-08 19:10:42 Edit:2012-04-08 23:49:37
çalışmadı
maalesef dediğin gibi denedim ama olmadı. modify altındaki kodların tamamını kaldırsamda resim adını kaydedebiliyorum.
2012-04-08 22:26:49
Edit:
Php
yazdığımı yapsan düzelir. $hedefdosya olarak bir dosya ismi girmelisin.
Her programcı birgün Php yi tadacaktır
2012-04-08 23:50:14