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 7783265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:47:12+00:00 2026-06-01T19:47:12+00:00

I have a script; $fileName = $_FILES[‘userfile’][‘name’]; $tmpName = $_FILES[‘userfile’][‘tmp_name’]; $fileSize = $_FILES[‘userfile’][‘size’]; $fileType

  • 0

I have a script;

        $fileName = $_FILES['userfile']['name'];
        $tmpName = $_FILES['userfile']['tmp_name'];
        $fileSize = $_FILES['userfile']['size'];
        $fileType = $_FILES['userfile']['type'];

        // get the file extension first
        $ext = substr(strrchr($fileName, "."), 1); 

        // make the random file name
        $randName = md5(rand() * time());

        // and now we have the unique file name for the upload file
        $filePath = $imagesDir . $randName . '.' . $ext;

        $result = move_uploaded_file($tmpName, $filePath);
        if (!$result) {
            echo "Error uploading file";
        exit;
    } 

if(!get_magic_quotes_gpc()) {

        $fileName = addslashes($fileName);
        $filePath = addslashes($filePath);

    }

which am using to upload images but I would like to add a script to resize the image to a specific size before it’s uploaded. How do I do that???

  • 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-06-01T19:47:14+00:00Added an answer on June 1, 2026 at 7:47 pm

    EDIT: I have updated this to include your script elements. I’m starting from the point where you obtain your filename.

    Here is a very quick, simple script to do it:

    $result = move_uploaded_file($tmpName, $filePath);
    $orig_image = imagecreatefromjpeg($filePath);
    $image_info = getimagesize($filePath); 
    $width_orig  = $image_info[0]; // current width as found in image file
    $height_orig = $image_info[1]; // current height as found in image file
    $width = 1024; // new image width
    $height = 768; // new image height
    $destination_image = imagecreatetruecolor($width, $height);
    imagecopyresampled($destination_image, $orig_image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
    // This will just copy the new image over the original at the same filePath.
    imagejpeg($destination_image, $filePath, 100);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Ruby 1.8.6 script that is supposed to take a filename that
I have this code in userpage.php: <script langauge=JavaScript><!-- function newWindow(fileName,windowName) { msgWindow=window.open(fileName,windowName); } //--></script>
Have a perl script that needs to process all files of a certain type
so I have a python script which takes the filename as a command argument
I have a script that creates files on multiple threads. Occassionally, I will get
The following code does not have any errors when run script.py -f filename but
I have a script to output graphic files via png() the filename is based
I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example),
i have a python script which keeps crashing on: subprocess.call([pdftotext, pdf_filename]) the error being:
I have script file where a command is stored in a variable First i

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.