0

Currently all the images got no extension after I upload and mysql store the images with no extension too. Any solution?

This is the code:

    <?php
    if(!empty($_POST['Name'])){
    if(!empty($_POST['SellPrice'])){
        if(!empty($_POST['RentPrice'])){
            if(!empty($_POST['Quantity'])){
                if(!empty($_POST['CostPrice'])){



$name = $_POST["Name"];
$SellPrice = $_POST["SellPrice"];
$RentPrice = $_POST["RentPrice"];
$Quantity = $_POST["Quantity"];
$CostPrice = $_POST["CostPrice"];
$Category = $_POST["Category"];
$name = mysql_real_escape_string($name);
$Category = mysql_real_escape_string($Category);
$desc = $_POST["editor1"];


if ((($_FILES["images"]["type"] == "image/gif")
|| ($_FILES["images"]["type"] == "image/jpeg")
||($_FILES["images"]["type"] == "image/png")
|| ($_FILES["images"]["type"] == "image/pjpeg"))){//5
  if ($_FILES["images"]["error"] > 0)
    {//4
    $target = "/images/none.gif";
    }//4
  else
    {//3

         $target = "/images/product/". mysql_insert_id().time() . $_FILES['images']['name']['type'];
         $target2 = "images/product/". mysql_insert_id().time() . $_FILES['images']['name']['type'];

$sql = "INSERT INTO product(Name,SellPrice,Category,Quantity,Cost_price,Rent_price,Images,Descr) VALUES ('$name','$SellPrice','$Category','$Quantity','$CostPrice','$RentPrice','$target','$desc')";

if (!mysql_query($sql,$con)){//1
die ('Error :' . mysql_error());}//1
if(move_uploaded_file($_FILES['images']['tmp_name'], $target2)) {//2
mysql_close($con);
header('Location: ../home.php');

}else{echo'Unable to upload the picture';   }//2
}//3
  }//5
  else{
             $target1 = "/images/none.gif";

$sql = "INSERT INTO product(Name,SellPrice,Category,Quantity,Cost_price,Rent_price,Images,Descr) VALUES ('$name','$SellPrice','$Category','$Quantity','$CostPrice','$RentPrice','$target1','$desc')";
if (!mysql_query($sql,$con)){//1
die ('Error :' . mysql_error());}//1
//2
mysql_close($con);
header('Location: ../home.php');

  }//5



                }else{echo'Please enter your cost price';}
            }else{echo'Please enter your quantity';}
        }else{echo'Please enter your rental price';}
    }else{echo'Please enter your sell price';}
}else{echo'Please enter product name';}


    ?>
2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by pritaeas
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.