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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:23:20+00:00 2026-06-03T05:23:20+00:00

I have an multiple image upload script, it resizes images and creates a thumbnail.

  • 0

I have an multiple image upload script, it resizes images and creates a thumbnail. for some odd reasons some images do are not going though. in this case the image size is small and it’s a JPEG type file. for some reason its not going through. it works perfectly with other images. I am using the same script for single files and it uploads that image file. please help! thanks!

<?php require_once("../includes/connection.php"); ?>
<?php require_once("../includes/functions.php"); ?>
<?php 
$albumName = $_GET['album'];
$albumDate = $_GET['date'];
$albumId = $_GET['id'];
$upload_path = "/home/elevat17/public_html/images/gallery/"; //location
$images = $_FILES['userFile']['name'];
$temps = $_FILES['userFile']['tmp_name'];
$types = $_FILES['userFile']['type'];
$errors = $_FILES["userFile"]["error"];
if ($_FILES["userFile"]["name"]=="") {echo "You must choose a file to upload!";}
if(in_array("", $images)) {die('Select an image to upload.');}


else

{
for ($n=0; isset($images[$n]) && isset($temps[$n]) && isset($types[$n]) && isset($errors[$n]); $n++) {
if ((($types[$n] == "image/gif")

|| ($types[$n] == "image/jpeg")

|| ($types[$n] == "image/pjpeg")

|| ($types[$n] == "image/png")

|| ($types[$n] == "image/jpg")

|| ($types[$n] == "image/x-png")))


{

if ($errors[$n] > 0)

{

$content =  "Return Code: " . $errors[$n] . "<br />";

}

else

{

$content =  "Upload: " . $images[$n] . "<br />";

$content =  "Type: " . $types[$n] . "<br />";

$content =  "<br/><br/>";



if (file_exists($upload_path . $images[$n]))

{

die($images[$n].' already exists. Upload cancelled!');

}

else

{

$uploadedfile = $temps[$n];

$image = $images[$n];

$size = getimagesize($uploadedfile);

$type = $size['mime'];

$width = $size[0];

$height = $size[1];

if($height > '900' || $width > '600')

{ 

$newwidth=600; // NEW WIDTH 

$newheight=($height/$width)*$newwidth;

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

$filename = $upload_path.$image;



if($size[2] == IMAGETYPE_GIF)

    {

        $src = imagecreatefromgif($uploadedfile);

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

        imagegif($tmp,$filename,100);

    }

elseif($size[2] == IMAGETYPE_JPEG)

    {

        $src = imagecreatefromjpeg($uploadedfile);

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

        imagejpeg($tmp,$filename,100);

    }

elseif($size[2] == IMAGETYPE_PNG) 

    {

        $src = imagecreatefrompng($uploadedfile);

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

        imagepng($tmp,$filename,9);

    }
crop_img(75,75);
move_uploaded_file($uploadedfile, $filename);
imagedestroy($src);

imagedestroy($tmp);

}

else

{      




}
$query = "INSERT INTO photos (photo_name, in_album) VALUES ('{$image}', $albumId)";
            if (mysql_query($query)) {header("location: edit_album.php?id={$albumId}");}




}

}

}

else { $content     =  "Invalid file"; }

}

}

?>
<?php require("../includes/footer.php"); ?>
  • 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-03T05:23:22+00:00Added an answer on June 3, 2026 at 5:23 am

    You’re not checking if the upload succeeded and are assuming it has. This is a bad way to write code. There is exactly ONE way for an upload to succeed, and MANY ways for it to fail.

    You’re also assuming the person doing the upload is not malicious and won’t simply rename their nastyvirus.exe to be cutekittens.jpg before uploading.

    At bare minimum, you need to have

    if ($_FILES['userfile']['error'] !== UPLOAD_ERR_OK) {
        die('Upload failed with error code ' . $_FILES['userfile']['error']);
    }
    

    to ensure you’ve actually got something useful to work with, and then use something like http://php.net/fileinfo to have the SERVER determine what the file’s type is.

    Never EVER trust what the user sends to you.

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

Sidebar

Related Questions

I have an image upload function that supports multiple files upload, but somehow it
I am trying to upload multiple images and I have a jquery plugin set
I am using Jquery Uploadify for images upload with PHP, here i have multiple
I want to use the Ajax-Upload script to upload multiple images. The kicker is
Hello I have a script that uploads multiple images (this script is composed of
I have a script where users can upload multiple files (max. 8). The HTML
I currently have an image upload input that only accepts PNG, JPG/JPEG, GIF images.
  I understand that elements can have multiple classes: .rfrsh-btn { background-image:url(../../upload/rfrsh_nb_grey.png); ... }
I have multiple DIVs containing an image in each. When I rollover these DIVs,
I am trying to create a multiple image uploader and I have come across

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.