This is my upload code, i want the file name to be it's own unique name so I was going to do a sql line work out the next row number and make this it's name.. so if the next row was
$newrownumber = 52;
How would I have $userfile_name to be 52 on this code?
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title>Multiple image upload script from plus2net.com</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<?
$add="../album/$userfile_name"; // the path with the file name where the file will be stored, upload is the directory name.
if(move_uploaded_file ($userfile, $add)){
echo "Successfully uploaded the mage";
chmod("$add",0777);
}else{echo "Failed to upload file Contact Site admin to fix the problem";
exit;}
///////// Start the thumbnail generation//////////////
//$n_width=100; // Fix the width of the thumb nail images
//$n_height=100; // Fix the height of the thumb nail imaage
$tsrc="../album/thumbs/$userfile_name"; // Path where thumb nail image will be stored
if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif")){echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
exit;}
/////////////////////////////////////////////// Starting of GIF thumb nail creation///////////
if (@$userfile_type=="image/gif")
{
$im=ImageCreateFromGIF($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
if ($hight == '2592' && $width == '1944') {
$n_width = 100;
$n_height = 75;
} elseif ($height == '1600' && $width == '1200') {
$n_width = 100;
$n_height = 75;
} elseif ($height == '1024' && $width == '768') {
$n_width = 100;
$n_height = 75;
} elseif ($height == '640' && $width == '480') {
$n_width = 100;
$n_height = 75;
} else {
$n_width = 100;
$n_height = 75;
}
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
if (function_exists("imagegif")) {
Header("Content-type: image/gif");
ImageGIF($newimage,$tsrc);
}
elseif (function_exists("imagejpeg")) {
Header("Content-type: image/jpeg");
ImageJPEG($newimage,$tsrc);
}
chmod("$tsrc",0777);
}////////// end of gif file thumb nail creation//////////
////////////// starting of JPG thumb nail creation//////////
if($userfile_type=="image/pjpeg"){
$im=ImageCreateFromJPEG($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
if ($hight == '2592' && $width == '1944') {
$n_width = 100;
$n_height = 75;
} elseif ($height == '1600' && $width == '1200') {
$n_width = 100;
$n_height = 75;
} elseif ($height == '1024' && $width == '768') {
$n_width = 100;
$n_height = 75;
} elseif ($height == '640' && $width == '480') {
$n_width = 100;
$n_height = 75;
} else {
$n_width = 100;
$n_height = 75;
}
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$tsrc);
chmod("$tsrc",0777);
}
//////////////// End of JPG thumb nail creation //////////
///////// Start the Mid generation//////////////
$vsrc="../album/mid/$userfile_name"; // Path where thumb nail image will be stored
if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif")){echo "Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
exit;}
/////////////////////////////////////////////// Starting of GIF Mid creation///////////
if (@$userfile_type=="image/gif")
{
$imm=ImageCreateFromGIF($add);
$width2=ImageSx($imm); // Original picture width is stored
$height2=ImageSy($imm); // Original picture height is stored
if ($hight2 == '2592' && $width2 == '1944') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($height2 == '1600' && $width2 == '1200') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($height2 == '1024' && $width2 == '768') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($height2 == '640' && $width2 == '480') {
$n_width2 = 600;
$n_height2 = 450;
} else {
$n_width2 = 600;
$n_height2 = 450;
}
$newimage2=imagecreatetruecolor($n_width2,$n_height2);
imageCopyResized($newimage2,$im,0,0,0,0,$n_width2,$n_height2,$width2,$height2);
if (function_exists("imagegif")) {
Header("Content-type: image/gif");
ImageGIF($newimage2,$vsrc);
}
elseif (function_exists("imagejpeg")) {
Header("Content-type: image/jpeg");
ImageJPEG($newimage2,$vsrc);
}
chmod("$tsrc",0777);
}////////// end of gif file thumb nail creation//////////
////////////// starting of JPG Mid creation//////////
if($userfile_type=="image/pjpeg"){
$imm=ImageCreateFromJPEG($add);
$width2=ImageSx($imm); // Original picture width is stored
$height2=ImageSy($imm); // Original picture height is stored
if ($hight2 == '2592' && $width2 == '1944') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($height2 == '1600' && $width2 == '1200') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($height2 == '1024' && $width2 == '768') {
$n_width2 = 600;
$n_height2 = 450;
} elseif ($height2 == '640' && $width2 == '480') {
$n_width2 = 600;
$n_height2 = 450;
} else {
$n_width2 = 600;
$n_height2 = 450;
}
$newimage2=imagecreatetruecolor($n_width2,$n_height2);
imageCopyResized($newimage2,$imm,0,0,0,0,$n_width2,$n_height2,$width2,$height2);
ImageJpeg($newimage2,$vsrc);
chmod("$tsrc",0777);
}
//////////////// End of JPG Mid creation //////////
mysql_connect (localhost, **, **);
mysql_select_db (table);
$result = mysql_query ("INSERT INTO trips (`id`,`thumb`,`main`,`mid`,`trip_id`) Values('','$userfile_name','$userfile_name','$userfile_name','$trip_id')") or die("INSERT error: ".mysql_error());
?>
</body>
</html>