Note :
1 . Path variable metion in your contant files.
2 . change 640 size as your depend size.
3. This code you can use for thumb images also
function multiImageUpload ($Menu_Name, $Car_Name, $Car_Id){
global $PATH_IMAGE;
//echo ‘<pre>’; print_r(sizeof($_FILES[‘ufile’][‘name’]));
for($i = 0; $i<=sizeof($_FILES[‘ufile’][‘name’]); $i++)
{
$image=$_FILES[‘ufile’][‘name’][$i];
$img_name = strtolower($Menu_Name) . substr($Car_Name, 0, 6);
if ($image)
{
$filename = stripslashes($_FILES[‘ufile’][‘name’][$i]);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != “jpg”) && ($extension != “jpeg”) && ($extension != “png”) && ($extension != “gif”))
{
echo ‘<h1>Unknown extension! Image 1</h1>’;
$errors=1;
}
else
{
$size=filesize($_FILES[‘ufile’][‘tmp_name’][$i]);
if ($size > MAX_SIZE*1024)
{
//echo ‘<h1>You have exceeded the size limit! Image 1</h1>’;
$errors=1;
}
$image_name= “images/cars/” . $Menu_Name . ‘/’ . $img_name . $i . ‘-cars.’.$extension;
$path= $PATH_IMAGE . $image_name;
if(file_exists($path))
{
unlink($path);
}
$copied = copy($_FILES[‘ufile’][‘tmp_name’][$i], $path);
$img = imagecreatefromjpeg($path);
$width = imagesx($img);
$height = imagesy($img);
$new_width = 640;
$new_height = floor( $height * ( 640 / $width ) );
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
imagejpeg( $tmp_img, $path);
if (!$copied)
{
echo ‘<h1>Copy unsuccessfull! Image 1</h1>’;
$errors=1;
}
else
{
$qrySelImagLinks = ” select * from car_img_link where Car_Id= ‘” . $Car_Id . “‘ and Img_Link='” . $image_name . “‘”;
$rsSelImagLinks = mysql_query($qrySelImagLinks);
$numrows = mysql_num_rows($rsSelImagLinks);
if($numrows > ‘0’){
if($filename == ”){
$updateCaImgLink = “update car_img_link set Car_Id='” . $Car_Id . “‘ Img_Link= ‘” . $image_name . “‘ where Car_Id= ‘” . $Car_Id . “‘”;
mysql_query($updateCaImgLink);
}else{
$updateCaImgLink = “update car_img_link set Car_Id='” . $Car_Id . “‘ Img_Link= ‘” . $image_name . “‘ where Car_Id= ‘” . $Car_Id . “‘ and Img_Link= ‘” . $image_name . “‘”;
mysql_query($updateCaImgLink);
}
}else{
$insertCarImgLink = “insert into car_img_link(Car_Id, Img_Link) values(‘” . $Car_Id . “‘, ‘” . $image_name . “‘)”;
mysql_query($insertCarImgLink) or die(mysql_error());
}
}
}
}
}
}
Introduction Git tags are an essential feature of version control systems, offering a simple way…
Introduction The methods that browsers employ to store data on a user's device are referred…
Introduction A well-known open-source VPN technology, OpenVPN provides strong protection for both people and businesses.…
Introduction Integrating Sentry into a Node.js, Express.js, and MongoDB backend project significantly enhances error tracking…
Introduction In the world of JavaScript development, efficiently managing asynchronous operations is essential. Asynchronous programming…
Introduction Let's Encrypt is a Certificate Authority (CA) that makes it simple to obtain and…