Please help uploading images

Hi all,

I have the following code to upload an image and save pathto DB:


<?php
$uploadDir = '../uploads/';

if(isset($_POST['upload']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

if($fileName==""){

$filePath = '../uploads/img/none.jpg';
}
else{

$filePath = $uploadDir . $fileName;
}

$filePath = str_replace(" ", "_", $filePath);
$result = move_uploaded_file($tmpName, $filePath);



if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
} 
$categoria = $_POST["id_categoria"];
$subcategoria = $_POST["id_subcategoria"];
$fabricante = $_POST["fabricante"];
$articuloesp = $_POST["articulo_esp"];
$articulocat = $_POST["articulo_cat"];
$precio = $_POST["precio"];
$descripcionesp = $_POST["descripcion_esp"];
$descripcioncat = $_POST["descripcion_cat"];
if(isset($_POST['novedad'])){
$novedad = 'si';
}
else{
$novedad = 'no';
}
$query = "INSERT INTO lacteosp.t_articulo (id_categoria,id_subcategoria,fabricante,articulo_esp,articulo_cat,precio,descripcion_esp,descripcion_cat,novedad,articulo_image) ".
"VALUES ('$categoria','$subcategoria','$fabricante','$articuloesp','$articulocat','$precio','$descripcionesp','$descripcioncat','$novedad','$filePath')";

mysql_query($query) or die('Error, query failed : ' . mysql_error()); 


//echo "<br>Files uploaded<br>";

header("Location: PC_products_inserted.php"); 
}
?>

this is working fine, but I need now to upload 2 images and save 2 paths to my DB. I am very new to php and having a hard time figuring out how to do this.
Can I modify the upload script to achieve this?
Thanks

absolutetly you can,you need two input tags…
any question please contact me with skype “lamb_137”

Sponsor our Newsletter | Privacy Policy | Terms of Service