Below is the start of the code that is supposed to resize images then save the resized image to a folder. I stuck an cannot figure out how to get file name and save the image after it has been resized. I used the same image code but this code saved the file and got the file name. the image was not altered as I’m trying to do.
any help is great
[code=php]
$res = copy($HTTP_POST_FILES[‘file’][‘tmp_name’][$i], $path.$user_name.”-“.$HTTP_POST_FILES[‘file’][‘name’][$i]);
if (!$res) {
$msg .= “upload failed!”;
header(“location: $url?msg=$msg”);
exit;
}
} else {
header(“location: $url?msg=$msg”);
$msg .=”Wrong file type, Must be jpeg, gif or png file types”; exit; }
$image = $user_name.”-“.$HTTP_POST_FILES[‘file’][‘name’][$i];
//Get Image Size
$image_size = $_FILES[‘file’][‘size’][$i];
[code=php]
// Upload Images
$path = ‘../user_images/’;
foreach ($_FILES[‘uploadImg’][‘tmp_name’] as $i => $val) :
if (is_uploaded_file($_FILES[‘uploadImg’][‘tmp_name’][$i])) {
/////////////////Check File Extentions
if (($_FILES[‘file’][‘type’][$i]==”image/gif”) || ($_FILES[‘file’][‘type’][$i]==”image/pjpeg”) || ($_FILES[‘file’][‘type’][$i]==”image/jpeg”) || ($_FILES[‘file’][‘type’][$i]==”image/png”)) {
if (file_exists($path . $_FILES[‘file’][‘name’][$i])) {
$msg .= “The file already exists, change your file name”;
header(“location: $url?msg=$msg”);
exit;
}
///////////////////
//// Resize Image Code
// Load image
$image = $_FILES[‘uploadImg’][‘tmp_name’][i];
if ($image === false) { die (‘Unable to open image’); }
// Get original width and height
$width = imagesx($image);
$height = imagesy($image);
// New width and height
$new_width = 90;
$new_height = 125;
// Resample
$image_resized = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Display resized image
header(‘Content-type: image/jpeg’);
imagejpeg($image_resized);
die();
///////
endforeach;
}
?>