Image Name:

Image Path:

"; } Image Upload
{ // get the time for a random image name $time = time(); $img_name = mysql_real_escape_string($_POST['image_name']); $image_dimensions = getimagesize($_FILES['image_to_upload']['tmp_name']); $image_height = $image_dimensions[1]; $image_width = $image_dimensions[0]; $errors = array(); if(empty($img_name) | | empty($image_dimensions)) { $errors[] = 'You did not enter an Image Name!'; } if(empty($_FILES['image_to_upload']['name'])) { $errors[] = 'You did not give a file to Upload!'; } if(!is_uploaded_file($_FILES['image_to_upload']['tmp_name'])) { $errors[] = 'Error while Uploading File.'; } if($_FILES['image_to_upload']['size'] > $max_file_size) { $errors[] = 'Your Image size was too Big. The maximum Size is '. $max_file_size . ' bytes.'; } // check the image type, gif or jpg/jpeg/psd/png is allowd if(!exif_imagetype($_FILES['image_to_upload']['tmp_name']) == IMAGETYPE_GIF || !exif_imagetype($_FILES['image_to_upload']['tmp_name']) == IMAGETYPE_JPEG || !exif_imagetype($_FILES['image_to_upload']['tmp_name']) ==IMAGETYPE_PSD || !exif_imagetype($_FILES['image_to_upload']['tmp_name']) == IMAGETYPE_PNG) { $errors[] = 'Your Image must be a JPEG, PSD, PNG, or GIF!'; } // check the Image dimensions if($image_height > $max_width) { $errors[] = 'Your Image height was too big.'; } if($image_width > $max_width) { $errors[] = 'Your Image width was too large.'; } if(count($errors) > 0) { echo 'ERRORS:
'; foreach($errors as $err) { echo $err . '
'; } } else { $image_url = $directory_to_upload . $time . '_' . $_FILES['image_to_upload']['name']; if(copy($_FILES['image_to_upload']['tmp_name'], $image_url)) { mysql_query("INSERT INTO uploaded_images (image_name, image_url) VALUES ('$img_name', '$image_url')"); echo 'Image uploaded Successfully. Click here to view your image