ecarpar
yukarıda yapılan post işleminde idyi alıp aşağıdaki işlemde yerine yazıcak.
if($_POST){
$note=htmlspecialchars($_POST["note"]);
$content=htmlspecialchars($_POST["content"]);
$category = $_POST['category'];
$notalang = $_COOKIE['lang'];
if (isset($_POST['status']))$status=0;else $status=1;
$time=date("d.m.Y H:i:s");
if($note!="" && $content!=""){
$sth = $db -> prepare ("INSERT INTO post (pid,title,content,category,status,time,lang,img) VALUES (?,?,?,?,?,?,?,?)");
$sth -> execute(array($id,$note,$content,$category,$status,$time,$notalang,$imcontrol));
}
aşağıdaki kod ise
$imcontrol=0;
extract($_FILES['files']);
$error=array();
$extension=array("jpeg","jpg","png","gif","PNG","JPEG","JPG");
mkdir("photo_gallery/".$id, 0700);
foreach(array_keys($_FILES["files"]["tmp_name"]) as $key=>$tmp_name){
$file_name=$_FILES["files"]["name"][$key];
$file_tmp=$_FILES["files"]["tmp_name"][$key];
$ext=pathinfo($file_name,PATHINFO_EXTENSION);
if(in_array($ext,$extension))
{
if(file_exists("photo_gallery/".$id."/".$file_name))
{
move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],"photo_gallery/".$id."/".$file_name);
}
else
{
$filename = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10);
$newFileName=$filename.time().".".$ext;
$sthaddfile = $db -> prepare ("INSERT INTO post_images (postid, url) VALUES (?,?)");
$sthaddfile -> execute(array($id,$newFileName));
$imcontrol=1;
move_uploaded_file($file_tmp=$_FILES["files"]["tmp_name"][$key],"photo_gallery/".$id."/".$newFileName);
}
}
else
{
array_push($error,"$file_name, ");
}
}