I am now thoroughly turned around on this whoel issue. User can upload up to 12 pictures with the name of the first image in the $pic1 variable and the image itself in $picfile1. I then need to resize the jpg to quality 60 and a certain size. It then gets put in a directory called boatpicts/ and the image should be named $boatid$pic1$order.jpg where $order = 1 etc...and then add the data to the db. This is what I have and I am very stuck. Just showing the first five. Am I on the right track even?
if ($submit != "") {
$pic1=$_REQUEST['pic1'];
$pic2=$_REQUEST['pic2'];
$pic3=$_REQUEST['pic3'];
$pic4=$_REQUEST['pic4'];
$pic5=$_REQUEST['pic5'];
$pic6=$_REQUEST['pic6'];
$pic7=$_REQUEST['pic7'];
$pic8=$_REQUEST['pic8'];
$pic9=$_REQUEST['pic9'];
$pic10=$_REQUEST['pic10'];
// set the directory
$boatid = "962";
$uploaddir = "/boatpicts/$boatid/";
// Picture 1
if (strlen($picfile1) > 0)
{
if (is_uploaded_file($picfile1))
{
$type="JPEG";
$end_path="$uploaddir"."$pic1";
$end_width= "400";
resize($picfile1,$end_path,$end_width,$type);
move_uploaded_file($picfile1, $uploaddir . $pic1 .".jpg");
}
$Sql="insert into vessel_media(vessel_pk,name,filename,display_order) values('$boatid','$pic1','$picfile1','1')";
mysql_query($Sql);
}
// Picture 2
if (strlen($picfile2) > 0)
{
if (is_uploaded_file($picfile2))
{
$type="JPEG";
$end_path="$uploaddir"."$pic2";
$end_width=400;
resize($picfile2,$end_path,$end_width,$type);
move_uploaded_file($picfile2, $uploaddir . $pic2 . ".jpg");
}
$Sql="insert into vessel_media(vessel_pk,name,filename,display_order) values('$boatid','$pic2','$picfile2','2')";
mysql_query($Sql);
}
// Picture 3
if (strlen($picfile3) > 0)
{
if (is_uploaded_file($picfile3))
{
$type="JPEG";
$end_path="$uploaddir"."$pic3";
$end_width=400;
resize($picfile3,$end_path,$end_width,$type);
move_uploaded_file($picfile3, $uploaddir. $pic3 . ".jpg");
}
$Sql="insert into vessel_media(vessel_pk,name,filename,display_order) values('$boatid','$pic3','$picfile3','3')";
mysql_query($Sql);
}
// Picture 4
if (strlen($picfile4) > 0)
{
if (is_uploaded_file($picfile4))
{
$type="JPEG";
$end_path="$uploaddir"."$pic4";
$end_width=400;
resize($picfile4,$end_path,$end_width,$type);
move_uploaded_file($picfile4, $uploaddir.$pic4.".jpg");
}
$Sql="insert into vessel_media(vessel_pk,name,filename,display_order) values('$boatid','$pic4','$picfile4','4')";
mysql_query($Sql);
}
}