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

  • Home
  • SEARCH
  • 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 3633416
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:39:01+00:00 2026-05-19T00:39:01+00:00

I have a php script for image upload as below <?php $LibID = $_POST[name];

  • 0

I have a php script for image upload as below

<?php
$LibID = $_POST[name];
 define ("MAX_SIZE","10000");
 function getExtension($str) {
         $i = strrpos($str,".");
         if (!$i) { return ""; }
         $l = strlen($str) - $i;
         $ext = substr($str,$i+1,$l);
         return $ext;
 }
 $errors=0;
    $image=$_FILES['image']['name'];
    if ($image)
    {
        $filename = stripslashes($_FILES['image']['name']);
        $extension = getExtension($filename);
        $extension = strtolower($extension);
 if (($extension != "jpg") && ($extension != "jpeg"))
        {
            echo '<h1>Unknown extension!</h1>';
            $errors=1;
            exit();
        }
        else
        {
 $size=filesize($_FILES['image']['tmp_name']);
if ($size > MAX_SIZE*1024)
{
    echo '<h1>You have exceeded the size limit!</h1>';
    $errors=1;
    exit();
}
$image_name=$LibID.'.'.$extension;
$newname="uimages/".$image_name;
$copied = copy($_FILES['image']['tmp_name'], $newname);
if (!$copied)
{
    echo '<h1>image upload unsuccessfull!</h1>';
    $errors=1;
    exit();
}}}
?>

which uploads the image file to a folder “uimages” in the root. I have made changes in the html file for the compact display of the image by defining “max-height” and “max-width”. But i want to resize the image file on upload. The image file may have a maximum width of 100px and maximum height of 150px. The image proportions must be constrained. That is, the image may be smaller than the above dimensions, but, it should not exceed the limit. How can I make this possible??

Thanks in advance 🙂

blasteralfred..

  • 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-19T00:39:01+00:00Added an answer on May 19, 2026 at 12:39 am

    See this answer, I like myself using imagemagick

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

Sidebar

Related Questions

I have a small php script which allows me to upload image file on
I have a file (image) upload script in PHP that I use to upload
I have a PHP script that initialises an image gallery. It loops through all
I have a PHP script that can encode a PNG image to a Base64
I have a php script which saves the original image, then resizes it -
I am trying to secure my PHP Image upload script and the last hurdle
I have a PHP script that runs as a CGI program and the HTTP
I have a PHP script that needs to determine if it's been executed via
I have a PHP script that sends critical e-mails. I know how to check
I have a PHP script that processes file uploads. The script tries to organise

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.