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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:05:47+00:00 2026-05-28T06:05:47+00:00

I have a requirement to upload image on server in 2 size, normal and

  • 0

I have a requirement to upload image on server in 2 size, normal and small size.

So i am sending http request to php file, i am successfully able to upload Image on server in normal form,

But when i am trying to resize and then uploading it on server, it is not uploading..

So here is my php script

<php

define ("MAX_SIZE","400");

if($_SERVER["REQUEST_METHOD"] == "POST")
{
   $image =$_FILES['userfile']['name'];
   $uploadedfile = $_FILES['userfile']['tmp_name'];

if ($image) 
{

    $filename = stripslashes($_FILES['userfile']['name']);

    $extension = getExtension($filename);
    $extension = strtolower($extension);

            if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) 
    {
        $errors=1;
    }
    else
    {
                    $size=filesize($_FILES['userfile']['tmp_name']);
                    if ($size > MAX_SIZE*1024)
                    {
                       $errors=1;
                    }
                    if($extension=="jpg" || $extension=="jpeg" )
                    {
                           $uploadedfile = $_FILES['userfile']['tmp_name'];
                           $src = imagecreatefromjpeg($uploadedfile);
                    }


                    list($width,$height)=getimagesize($uploadedfile);

                    $newwidth = 70;                  
                    $newheight = 70;

                    $tmp = imagecreatetruecolor($newwidth,$newheight);

                    imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);



                    $file_name = substr ( md5(uniqid(rand(),1)), 5, 15); 


                    $iconuploaddir = "/home/announce/public_html/TravelApp/images/$output/icons/";

                    $file = basename($_FILES['userfile']['name']);
                    $newname = $file_name . $file;

                    $uploadIconfile = $iconuploaddir . $newname;


                    if (move_uploaded_file($temp, $uploadIconfile)) {
                           $imagepath =  $baseuploaddir;// Give the path where the image saves. or print some messages
                    }

                    imagedestroy($src);
                    imagedestroy($tmp);                      
           }
        }
 }
?>

i guess move_uploaded_file($temp, $uploadIconfile)) is the main cause of problem

please help me.

  • 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-28T06:05:47+00:00Added an answer on May 28, 2026 at 6:05 am

    You cannot be using move_uploaded_file for the thumbnail because the thumbnail file was not uploaded

    You can use this function to create the thumbnail after calling move_uploaded_file for the file that was uploaded

    function make_thumb($src,$dest,$desired_width)
    {
    
      /* read the source image */
      $source_image = imagecreatefromjpeg($src);
      $width = imagesx($source_image);
      $height = imagesy($source_image);
    
      /* find the "desired height" of this thumbnail, relative to the desired width  */
      $desired_height = floor($height*($desired_width/$width));
    
      /* create a new, "virtual" image */
      $virtual_image = imagecreatetruecolor($desired_width,$desired_height);
    
      /* copy source image at a resized size */
      imagecopyresized($virtual_image,$source_image,0,0,0,0,$desired_width,$desired_height,$width,$height);
    
      /* create the physical thumbnail image to its destination */
      imagejpeg($virtual_image,$dest);
    }

    For the $src param pass $imagepath and for $dest, put the destination you want the thumbmail image to be saved.

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

Sidebar

Related Questions

We have a webapp where people can upload various image file types and on
I have a requirement where I have to upload a file to db. File
I have a requirement to allow 30 mb of file upload via my web
I have a web application with a simple file upload requirement (max 1 mb).
We have an requirement in our project to browse & upload an XML file
I have a requirement to be able to provide a flex component in English
I have a requirement to be be able to embed scanned tiff images into
I have requirement where I need to allow users to upload a Word document
I have a requirement to create a job where a web upload (IE a
I have an aspx website and I'd like to upload a file to it.

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.