I'm using this code that getting data from articles form, to save images of the articles and showing them in a news slider:
if(isset($_POST['submit']))
{
unset($_SESSION['firsttitle']);
unset($_SESSION['firstcontent']);
unset($_SESSION['title']);
unset($_SESSION['content']);
unset($_SESSION['thirdcontent']);
$_SESSION['title']=mysql_real_escape_string(trim($_POST['title']));
$_SESSION['content']=mysql_real_escape_string(trim($_POST['content']));
$weight=htmlentities(trim($_REQUEST['weight']),ENT_QUOTES);
$id=$_REQUEST['id'];
$time=mktime();
if($_FILES['picture']['name'])
{
$select="select * from ".$prev."news where id='$id'";
$re_select=mysql_query($select);
$d_select=mysql_fetch_array($re_select);
if($d_select['picture']!='')
{
unlink("../".$d_select['picture']);
}
$picture="upload/".$time.$_FILES['picture']['name'];
$path="../".$picture;
move_uploaded_file($_FILES['picture']['tmp_name'],$path);
}
else
{
$picture=$_POST['picturepath'];
}
if($id=='0' || !$_REQUEST['id'])
{
$insert="insert into ".$prev."news (title,content,weight,picture,status,postedtime) values('".$_SESSION['title']."','".$_SESSION['content']."','$weight','$picture','Y','$time')";
mysql_query($insert);
$lastid=mysql_insert_id();
unset($_SESSION['title']);
unset($_SESSION['content']);
@header("location:news-addnew.php?id=$lastid");
}
else
{
$update="update ".$prev."news set title='".$_SESSION['title']."',content='".$_SESSION['content']."',weight='$weight',picture='$picture',status='$status',postedtime='$time' where id='$id'";
mysql_query($update);
unset($_SESSION['title']);
unset($_SESSION['content']);
@header("location:news-addnew.php?id=$id");
}
}
how can I add a function to save a thumbnail for the image within the same directory that this code saving the original image?