what i am trying to do is when an admin tries to create a new product to upload to the server an image of that and as it's name to be the product id.jpg. I have searched google with no result. The code seems to be right. Can someone help me please? I am using lamp as local test server.
<?php
// Parse the form data and add inventory item to the system
if (isset($_POST['product_name'])) {
$product_name = mysql_real_escape_string($_POST['product_name']);
$price = mysql_real_escape_string($_POST['price']);
$details = mysql_real_escape_string($_POST['details']);
$category = mysql_real_escape_string($_POST['category_choice']);
$condition= mysql_real_escape_string($_POST['condition']);
$supplier_choice= mysql_real_escape_string($_POST['supplier_choice']);
$handling_time= mysql_real_escape_string($_POST['handling_time']);
$weight= mysql_real_escape_string($_POST['weight']);
$information_box= $_POST['information'];
$pid = mysql_insert_id();
// Place image in the folder
$newname = "$pid.jpg";
move_uploaded_file( $_FILES['my_photo']['tmp_name'], "../inventory_images/$newname");
header("location: products.php");
exit();
}
?>
<form action="add_product.php" enctype="multipart/form-data" name="my_Form" id="my_Form" method="post">
<tr>
<td>Φωτογραφία</td>
<td>
<label>
<input type="file" name="my_photo" id="my_photo"/>
</label>
</td>
</tr>
<tr>
<td> </td>
<td>
<label>
<input type="submit" name="button" id="button" value="Αποθήκευση" />
</label>
</td>
</tr>
</table>
</form>