jump to navigation

Delete image (uploaded throw ajax unlimited image) November 6, 2009

Posted by ashwinisingh in PHP.
Tags:
add a comment

require(‘../configuration/config.php’);

$id=$_REQUEST[‘id’];
//echo $id;
$ins=”SELECT * FROM  table  where id='”.$id.”‘ “;
$result=mysql_query($ins);
$row=mysql_fetch_array($result);
$image1=$row[‘images’];
$newimg=(explode(“,”,$image1));
$count=count($newimg);

$countnew=$count-1;

if(isset($_REQUEST[‘action’]))
{

$full=”../uploads/”;
$img=$_REQUEST[‘val’];
$id=$_REQUEST[‘id’];
for($i=0;$i<$countnew;$i++)
{
if($newimg[$i]==$img)
{

unset($newimg[$i]);
//echo found;
}
}
//print_r($newimg);
$updateimg=implode(“,”,$newimg);
$query=”update table  set images='”.$updateimg.”‘where id=’$id'”;
$result=mysql_query($query) or die(“select query not run”);
$path=$full.$img;
if(file_exists($path))
{
unlink($full.$img);
}