Resize image from its path and reupload resized image path in db

by Zeeshan Ahmed   Last Updated August 16, 2017 09:05 AM

I have taken an image as upload with html input. I have stored the image path in MySql DB and image in a file. Next what I want to do is: 1. use that file path to resize image. 2. display it in a box which is 450X450 3. store new resize image path in DB and image in file. 4. delete original image.

This is my code so far:

                $image_name = $_FILES['uploadedimage']['name'];
                $temp_image_path = "user_upload/temp_image/"; //image path
                $temp_image_name = time().$image_name; //renaming the file here
                if(move_uploaded_file($_FILES['uploadedimage']['tmp_name'], $temp_image_path.$temp_image_name)){
                mysqli_query($dbc,"INSERT INTO temp_image (temp_img_path, unique_key) VALUES ('$temp_image_path$temp_image_name', '$unique_key')");
                echo '<div id="focus">';
                echo '<div id="img_crop">';
                echo '<div id="image_inside">';
                echo "<img src='$temp_image_path$temp_image_name' id='crop'/>";
                echo '</div>';
                echo '<div id="border_crop">';
                echo '</div>';
                echo '</div>';
                echo '</div>';

With these lines of codes I am able to display the uploaded image in the box of 450x450 but since the image is very large it's all over the webpage instead of being in the box. please help. Thanks.

Tags : php mysql html

Related Questions

How can i upload multiple images to an column in MYSQL

Updated December 04, 2018 00:05 AM