genesisvh
asked on
SimpleImage.php question
I have a form where I'll be uploading images. I found a script that will resize the images. This the link to it SimpleImage.php Where on the script can I include this and how? Below is the script I'm using to upload multiple images an d text.
<?php
session_start();
$error="";
//error_reporting(E_ALL);
// image upload folder
$image_folder = 'images/classified/';
// fieldnames in form
$all_file_fields = array('image1', 'image2' ,'image3', 'image4');
// allowed filetypes
$file_types = array('jpg','gif','png');
// max filesize 5mb
$max_size = 5000000;
//echo'<pre>';print_r($_FILES);exit;
$time = time();
$count = 1;
foreach($all_file_fields as $fieldname){
if($_FILES[$fieldname]['name'] != ''){
$type = substr($_FILES[$fieldname]['name'], -3, 3);
// check filetype
if(in_array(strtolower($type), $file_types)){
//check filesize
if($_FILES[$fieldname]['size']>$max_size){
$error = "File too big. Max filesize is ".$max_size." MB";
}else{
// new filename
$filename = str_replace(' ','',$myusername).'_'.$time.'_'.$count.'.'.$type;
// move/upload file
$target_path = $image_folder.basename($filename);
move_uploaded_file($_FILES[$fieldname]['tmp_name'], $target_path);
//save array with filenames
$images[$count] = $image_folder.$filename;
$count = $count+1;
}//end if
}else{ $error = "Please use jpg, gif, png files";
}//end if
}//end if
}//end foreach
if($error != ''){ echo $error;
}else{
/* --------------------------------------------------------------------------------------------------
SAVE TO DATABASE ------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------- */
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Pleases find the attachment for the image re size once you uploaded the images,
These are the functions which i have used to make the image upload and resize - that is crop
functions.php