Hey there.
Basically I want to upload images that I insert into my database via php.
This is the code relevant to the php part.
[QUOTE]
<?php
if(isset($_POST[‘insert_post’])){
//getting the text data from the fields
$product_title = $_POST[‘product_title’];
$product_cat = $_POST[‘product_cat’];
$product_manufacturer = $_POST[‘product_manufacturer’];
$product_price= $_POST[‘product_price’];
$product_desc = $_POST[‘product_desc’];
$product_keywords = $_POST[‘product_keywords’];
//getting the image from the field product_image
$product_image = $_FILES[‘product_image’][‘name’];
$product_image_tmp = $_FILES[‘product_image’][‘tmp_name’];
move_uploaded_file($product_image_tmp, ‘product_images/$product_image’);
$insert_product = “INSERT INTO products VALUES(”,’$product_title’,’$product_cat’,’$product_manufacturer’,’$product_price’,’$product_desc’,’$product_image’,’$product_keywords’)”;
$insert_stuff = mysqli_query($con, $insert_product);
if($insert_stuff){
echo”<script>alert(‘Product has been inserted’)</script>”;
echo”<script>window.open(‘insert_product.php’,’_self’)</script>”;
}
}
The thing is, whenever I insert a new product, that exact same image replaces the former one, and so on. What I wanted is to have all the pictures of all the products I insert into the database being uploaded in that folder (product_images) and not replacing themselves 1 by 1.
Thanks in advance.