Hey there,
I have a problem getting an image to upload.
Ive got a form…
[code]
Product Name:
File:
Description:
Price:
[php]<?php
require (“connect.php”);
require(“adminCheck.php”);
if(isset($_POST[‘submit’],$_FILES[‘image’])){
$prod_name = $_POST[‘name’];
$descr = $_POST[‘desc’];
$price = $_POST[‘price’];
$image_name = $_FILES['image']['name'];
$image_size = $_FILES['image']['size'];
$image_temp = $_FILES['image']['tmp_name'];
$ext_allow = array('jpg', 'jpeg', 'png', 'gif');
$ext = strtolower(end(explode('.',$image_name)));
if ($ext)
{
$_query = mysql_query("INSERT INTO product (product_name,description, product_price,ext,user_name) VALUES ('".addslashes($prod_name) ."','".addslashes($descr)."','".addslashes($price)."','".addslashes($ext)."','".addslashes($_SESSION['username'])."')") or die(mysql_error);
$img_id = mysql_insert_id();
$img_file = $img_id.'.'.$ext;
echo $img_file;
move_uploaded_file($image_tmp, 'Images/'.$img_file);
}
}
?>[/php]
Which posts to the same page.
I then get the name, size and tmp_name for that img and all the other details and set them in variables, do an sql statment to insert the data into a database.
After that i get the id i gave the image in the database and i try to upload the image to the images directory with that id.
The problem that i am having is the image isnt being uploaded to the directory.
Any help/suggestions are welcome.
Thanks