Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6054733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:11:10+00:00 2026-05-23T08:11:10+00:00

Now I have an insert form just like that: $sql=INSERT INTO products (pname, pcat,

  • 0

Now I have an insert form just like that:

$sql="INSERT INTO products (pname, pcat, pimg1, pimg2, pimg3, pnotes, pclient, pclientaddress, pclientphone)
VALUES
('$_POST[pname]','$_POST[pcat]','$_POST[pimg1]','$_POST[pimg2]','$_POST[pimg3]','$_POST[pnotes]','$_POST[pclient]','$_POST[pclientaddress]','$_POST[pclientphone]')";

Instead of entering the URL value of three different images, is there a way I can upload one image and have there different sizes of it, the original one to be named 1001a and two other 1001 and 1001b?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:11:11+00:00Added an answer on May 23, 2026 at 8:11 am

    Find below php code to upload and crop image using GD library. You can save only one image name in database and other croped images will be access using the same name, but it should be stored in different-different directory as below:

    <?php
    function createThumb($upfile, $dstfile, $max_width, $max_height){
       $size = getimagesize($upfile);
       $width = $size[0];
       $height = $size[1];
       $x_ratio = $max_width / $width;
       $y_ratio = $max_height / $height;
       if( ($width <= $max_width) && ($height <= $max_height)) {
               $tn_width = $width;
               $tn_height = $height;
       } elseif (($x_ratio * $height) < $max_height) {
               $tn_height = ceil($x_ratio * $height);
               $tn_width = $max_width;
       } else {
               $tn_width = ceil($y_ratio * $width);
               $tn_height = $max_height;
       }
       if($size['mime'] == "image/jpeg"){
               $src = ImageCreateFromJpeg($upfile);
               $dst = ImageCreateTrueColor($tn_width, $tn_height);
               imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height);
               imageinterlace( $dst, true);
               ImageJpeg($dst, $dstfile, 100);
       } else if ($size['mime'] == "image/png"){
               $src = ImageCreateFrompng($upfile);
               $dst = ImageCreateTrueColor($tn_width, $tn_height);
               imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height);
               Imagepng($dst, $dstfile);
    
       } else {
    
               $src = ImageCreateFromGif($upfile);
               $dst = ImageCreateTrueColor($tn_width, $tn_height);
               imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width, $tn_height,$width, $height);
               imagegif($dst, $dstfile);
       }
    }
    
    //usage
    
    if(isset($_FILES['upload_Image']['name']) && $_FILES['upload_Image']['name']!=='') {
        $ext = substr($_FILES['upload_Image']['name'], strpos($_FILES['upload_Image']['name'],'.'), strlen($_FILES['upload_Image']['name'])-1); 
    
        $imgNormal = time().$ext;
        $normalDestination = "Photos/Orignal/" . $imgNormal;
        $httpRootLarge = "Photos/Large/" . $imgNormal;
        $httpRootSmall = "Photos/Small/" . $imgNormal;
        $httpRootThumb = "Photos/Thumb/" . $imgNormal;
        move_uploaded_file($_FILES['upload_Image']['tmp_name'], $normalDestination);
        createThumb($normalDestination,$httpRootLarge,680,604); #For 604x604 Image 
        createThumb($normalDestination,$httpRootSmall,500,300); #For 500x300 Image
        createThumb($normalDestination,$httpRootThumb,130,100); #For 130x100 Image
    }
    ?>
    <form action="" method="post" enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="upload_Image" id="upload_Image" />
    <br />
    <input type="submit" name="submit" value="Submit" />
    </form>
    

    You need to store $imgNormal value in database only.

    for more reference click on below link:

    http://pastebin.com/Ed2YHV6w

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just finished creating my signup form and now ready to insert data
Now that I have a read-only application working, I am working on the insert
With help from you guys I now have a script that works like a
I have a Groups table and a Participants table. Now I need to insert
I now have it set up so that when people go to a thank
I now have a running Java program which only lacks of the final step,that
Following on from this question I now have code that can attach to a
I have a search form that can search in different provider. I started out
I have a partial now looking like this: <%= render(:partial => 'order', :object =>
My DB has columns: ID, first_name, email, password, level I have a form that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.