ABZiko
چهارشنبه 20 اسفند 1393, 18:06 عصر
سلام، این کد بنده برای آپدیت کردن نام تصویر سه جدول هست (لایه آخر):
case'updateAvatar':{
$fileName=$_FILES['file']['name'];
$tmp=$_FILES['file']['tmp_name'];
$type=$_FILES['file']['type'];
$arr=array('image/png','image/jpeg','image/gif');
$mime = array('image/png' => 'png', 'image/jpeg' => 'jpg', 'image/gif' => 'gif');
if(in_array($type,$arr)){
if(is_uploaded_file($tmp)){
$newName = md5($fileName . time() . rand(1, 99999));
if (move_uploaded_file($tmp,'Uploads/'.$newName.'.'.$mime[$type])){
echo "<div style='font-family:Segoe UI'>Your File Uploaded !</div>";}}}
$objUser=new User();
$result=$objUser->updateAvatar($_POST['id'],$newName.'.'.$mime[$type]);
$result=$objUser->updateAuthorAvatar($_POST['id'],$newName.'.'.$mime[$type]);
$result=$objUser->updateCommentAvatar($_POST['id'],$newName.'.'.$mime[$type]);
if($result==0){
echo "<div style='font-family:Segoe UI'>Your Row Updated !</div>";
header('Refresh:5;Location:DashBoard.php');}
else{
echo "<div style='font-family:Segoe UI'>A Problem !</div>";
header('Refresh:5;Location:DashBoard.php');}}
break;
لایه دوم :
public function updateAvatar($id,$file){
$sql="UPDATE user SET file='$file' WHERE id='$id'";
return $con=Database::Execute($sql);}
public function updateAuthorAvatar($id,$file){
$sql="UPDATE product SET avatar='$file' WHERE userID='$id'";
return $con=Database::Execute($sql);}
public function updateCommentAvatar($id,$file){
$sql="UPDATE comment SET file='$file' WHERE userID='$id'";
return $con=Database::Execute($sql);}
اما بعد از آپدیت :
جدول محصول : 3c4a612e4f1dbb3d58e7492a71dd4b8c.png
جدول کاربر : 3c4a612e4f1dbb3d58e7492a71dd4b8c.png
جدول نظر : 3c4a612e4f1dbb3d58e7492a7
حالا سوالم اینه که چرا توی جدول سومی، حدود 1/3 نوشته ، ثبت نمی شه؟
case'updateAvatar':{
$fileName=$_FILES['file']['name'];
$tmp=$_FILES['file']['tmp_name'];
$type=$_FILES['file']['type'];
$arr=array('image/png','image/jpeg','image/gif');
$mime = array('image/png' => 'png', 'image/jpeg' => 'jpg', 'image/gif' => 'gif');
if(in_array($type,$arr)){
if(is_uploaded_file($tmp)){
$newName = md5($fileName . time() . rand(1, 99999));
if (move_uploaded_file($tmp,'Uploads/'.$newName.'.'.$mime[$type])){
echo "<div style='font-family:Segoe UI'>Your File Uploaded !</div>";}}}
$objUser=new User();
$result=$objUser->updateAvatar($_POST['id'],$newName.'.'.$mime[$type]);
$result=$objUser->updateAuthorAvatar($_POST['id'],$newName.'.'.$mime[$type]);
$result=$objUser->updateCommentAvatar($_POST['id'],$newName.'.'.$mime[$type]);
if($result==0){
echo "<div style='font-family:Segoe UI'>Your Row Updated !</div>";
header('Refresh:5;Location:DashBoard.php');}
else{
echo "<div style='font-family:Segoe UI'>A Problem !</div>";
header('Refresh:5;Location:DashBoard.php');}}
break;
لایه دوم :
public function updateAvatar($id,$file){
$sql="UPDATE user SET file='$file' WHERE id='$id'";
return $con=Database::Execute($sql);}
public function updateAuthorAvatar($id,$file){
$sql="UPDATE product SET avatar='$file' WHERE userID='$id'";
return $con=Database::Execute($sql);}
public function updateCommentAvatar($id,$file){
$sql="UPDATE comment SET file='$file' WHERE userID='$id'";
return $con=Database::Execute($sql);}
اما بعد از آپدیت :
جدول محصول : 3c4a612e4f1dbb3d58e7492a71dd4b8c.png
جدول کاربر : 3c4a612e4f1dbb3d58e7492a71dd4b8c.png
جدول نظر : 3c4a612e4f1dbb3d58e7492a7
حالا سوالم اینه که چرا توی جدول سومی، حدود 1/3 نوشته ، ثبت نمی شه؟