<?php
function getExtn($filename){
$ext = explode(".",$filename);
return $ext[1];
}
$imgfile="";
include '../connection.php';
$slno = $_POST["slno"];
if(is_array($_FILES)){
if(is_uploaded_file($_FILES['userImage']['tmp_name'])) {
$sourcePath = $_FILES['userImage']['tmp_name'];
$fileext = getExtn($_FILES['userImage']['name']);
$imgfile ="slider".time().rand(10,100).".".$fileext;
if(move_uploaded_file($sourcePath,"../img/".$imgfile)){
@unlink("../img/".$img);
?>
<?php
}
}
}
if(empty($slno)){
$insert = "insert into slider(img)values('$imgfile')";
$exc = $mysqli->query($insert);
echo "Slider Add Succesfully";
}else{
$update = "update slider set img='$imgfile' where id='$slno'";
$exc = $mysqli->query($update);
echo "Slider Update Succesfully";
}
?> |