Here is my image checking code:
session_start();
if ($photo1 != "none" or $photo2 != "none" or $photo3 != "none" or $photo4 != "none" or $photo5 != "none" or $photo6 != "none")
{
$i=0;
$numphotos=0;
$imageno=1;
$array=array();
while ($i<6)
{
$i++;
$photo=photo;
$photo.=$i;
if ( is_uploaded_file ( $HTTP_POST_FILES[$photo]['tmp_name']) ) {
$imagetype=$HTTP_POST_FILES[$photo]['type'];
if($imagetype=='image/pjpeg' || $imagetype=='image/gif') {}
else { $error="One or more of your image types were unsupported"; }
$array[$imageno] = $$photo;
$imageno++;
$numphotos++;
}
}
}
else {$empty="Y";}
Then it uploads it ot where it should go:
include("includes/connectdb.php");
if ($error==NULL)
{
$timestart=time();
mysql_query(" insert into classifieds
( status, title, guitar, price, timestart, timeend, condition, tremlo, yearmade, serialno,
countryorigin, originalparts, necktype, description, postageprice, postageservice,
postalinsurance, collection, userid, link1, link2, link3, link4)
values
('1','$title', '$guitar', '$price', '$timestart', '$duration', '$condition', '$tremlo'
, '$yearmade', '$serialno', '$countryorigin', '$originalparts', '$necktype',
'$description', '$postageprice', '$postageservice', '$postalinsurance',
'$collection', '$userid', '$linkarray[1]', '$linkarray[2]', '$linkarray[3]', '$linkarray[4]') ")
or print ( mysql_error() );
if ($empty!="Y") {
$info=mysql_query("select * from classifieds where title='$title' and price='$price' and description='$description'");
while ($row=mysql_fetch_array($info))
{
$classid=$row[id];
}
$i=0;
$imagepath="C:/phpdev/www/templatesite/ftpupload/$classid/";
while ($i<=$numphotos)
{
if ($i==0 ) { mkdir("$imagepath", 077 ); }
move_uploaded_file( $array[$i] , "C:/phpdev/www/templatesite/ftpupload/$classid/$i.jpg");
$i++;
}
$photo="insert into classphotos (id, numphotos";
$i=1;
while ($i<=$numphotos)
{
$photo .= ",photo";
$photo .= $i;
$i++;
}
$photo .= ") values ('";
$photo .= $classid;
$photo .="','";
$photo .= $numphotos;
$photo .="'";
$i=1;
while ($i<=$numphotos)
{
$photo .= ",'";
$photo .= $imagepath;
$photo .= $i;
$photo .= ".jpg";
$photo .= "'";
$i++;
}
$photo .= ")";
mysql_query("$photo") or die (mysql_error() );
}
}
else { print "<script> location.href='listguitar.php?error=$error' </script>"; die("$error"); }
How would I go about implementing it?
Thanks. Jack.