at the moment when i upload an image. a script is run to create a thumbnail and moves that to another folder and a the main image that i uploaded gets uploaded aswell. what i want to do is when i upload the image try and run the script again but with a different maxwidth and maxheight so it creates an image viewable on the screen when the user clicks on the thumbnail.
so far my code looks like this:
<?php
$max_size=5*1024*1024;
// Check if a file has been uploaded
if(isset($_FILES['uploaded_file']) && preg_match("/image\/jpeg|image\/jpg/i",$_FILES['uploaded_file']['type']) && $_FILES['uploaded_file']['size']<= $max_size)
{
// Make sure the file was sent without errors
if($_FILES['uploaded_file']['error'] == 0)
{
$target_path = "images/";
$target_path = $target_path . basename( $_FILES['uploaded_file']['name']);
if(!file_exists($target_path)){
if(move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $target_path))
{
$image = $target_path;
$maxHeight = 90; $maxWidth = 150;
include 'thumb_save.php'; // Save a thumb of uploaded pic
echo "The file ". basename($_FILES['uploaded_file']['name']). " has been uploaded";
$dbLink = new mysqli('localhost', 'root', '', 'gallery');
if(mysqli_connect_errno()) {
die("MySQL connection failed: ". mysqli_connect_error());
}
// Gather all required data
$name = $dbLink->real_escape_string($_FILES['uploaded_file']['name']);
$mime = $dbLink->real_escape_string($_FILES['uploaded_file']['type']);
$size = intval($_FILES['uploaded_file']['size']);
$image_path = $dbLink->real_escape_string($target_path);
$gallery_type = $dbLink->real_escape_string($_POST['gallery_type']);
$desc = $dbLink->real_escape_string($_POST['desc']);
$image_path = $dbLink->real_escape_string($target_path);
$tmb_name = $dbLink->real_escape_string($tmb_name);
//query to insert the data i had gathered into the database
$query = "INSERT INTO `images` (`name`, `size`, `created`, `image_path`, `gallery_type_id`, `desc`, `thumbnail_path` )
VALUES ('{$name}', {$size}, NOW(), '{$image_path}', '{$gallery_type}', '{$desc}', '{$tmb_name}')";
//executes the query
$dbLink->query($query);
}
}
else
{
echo 'A file with the same name exists please change the file name and try again';
}
}
else
{
echo 'A file was not sent';
}
}
else
{
echo 'The file is too large';
}
// Echo a link back to the main page
echo '<p>Click <a href="member-index.php">here</a> to go back</p>';
?>
as you see i include a script. i was wondering how would i set maxwidth and maxheight with them already set in this code for that script for the image i want at a certain height?
i know that might be hard to undertstand so please ask anything you would like explaining again.
thanks