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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:39:14+00:00 2026-05-23T02:39:14+00:00

I got a problem with a web upload. It is as follows: I upload

  • 0

I got a problem with a web upload. It is as follows:

I upload a picture and I look for the type (allowed jpeg, jpg, gif and png). Now I cut a part out of it and save it on a temporary resource which is created by the information of the type (if the type is jpg or jpeg, I use imagejpeg(), with PNG i use imagepng() and with gif I use imagegif()). Now this works. Then I save the images again.

And then I re-open them by imagecreatefromjpeg/-png/-gif. And then I get the error

Warning: imagecreatefromgif() [function.imagecreatefromgif]: 'uploads/gif/test.gif' is not a valid GIF file in /home/blabla/sliceit.php on line 88

Line 88 looks as follows:

$org_img = 'uploads/' . $name . "/" . $rand . (substr($type,0,1) != "." ? "." . $type : $type);

...

87: elseif ($type == ".gif") {
88:     $src_img = imagecreatefromgif($org_img);
89: }

The same error happens also with png, but not with jpeg (because I wrote the following statement at the beginning:

ini_set('gd.jpeg_ignore_warning', 1);

). Jpeg warnings seem to be deactivated, but not the warnings for png and gif. And I created the image with mspaint, so they actually have to be valid.

Thanks for help.

Flo

EDIT: some code:

$name = 'something';
$filetype = substr($_FILES['datei']['name'],-4,4);
$filetype = strtolower($filetype);
$randomsessid = randomstring(60);
mkdir('uploads/' . $name);
move_uploaded_file($_FILES['datei']['tmp_name'],'uploads/' . $name . '/' . $randomsessid . (substr($filetype,0,1) == "." ? $filetype : "." . $filetype));
mysql_query("INSERT INTO SESSIONS VALUES('','" . $name . "','" . $randomsessid . "','" . strtolower($filetype) . "'," . time() . ")");

So now I got the file saved and the information in my table.

Now I’m linking to another file…

$id = mysql_real_escape_string($_GET["randid"]); //here I get the randomstring
if ($id == "") {
    exit;
} 
$unf = mysql_query("SELECT NAME, TYP FROM SESSIONS WHERE RANDOM = '" . $id . "'");
if (mysql_num_rows($unf) == 1) {
    $f = mysql_fetch_object($unf);
    $name = $f->NAME;
    $filetype = $f->TYP;
}
else {
    exit;
}
$image_resize = new image_resize; //this is a very useful class to resize images

$size = $_GET["size"]; //here is 'auto' inside
$log->debug('size: ' . $size);
if ($size == "custom" and isset($_GET["x"]) and isset($_GET["y"])) {
    //blabla some code...
}
else {
    $image_resize->load("uploads/" . $name . "/" . $id . (substr($filetype,0,1) == "." ? $filetype : "." . $filetype));    
    $image_resize->resize(600,600);
    $image_resize->save("uploads/" . $name . "/" . $id . (substr($filetype,0,1) == "." ? $filetype : "." . $filetype));
}

And now another redirect ….

ini_set('gd.jpeg_ignore_warning', 1);
$id = $_GET["randid"];
if ($id == "") {
    exit;
}
$tempsel = "SELECT * FROM SESSIONS WHERE RANDOM = '" . $id . "'";
$unf = mysql_query($tempsel);
if (mysql_num_rows($unf) != 1) {
    $log->debug('tempsel: ' . $tempsel);
    exit;
}
$f = mysql_fetch_object($unf);
$name = $f->NAME;
$type = $f->TYP;
for ($i = 1; $i <= 9; $i++) {
    createImagePart($i,$name,$type,$id,$log); //$i = for loop, $name = the name from the beginning, $type defined, $id = random id, $log = a previously defined log class.
}

And the called function createImagePartI():

function createImagePart($nr,$name,$type,$id,$log) {
    if (!isFolderSet($id . "/parts/")) {
        mkdir("uploads/" . $id );
        mkdir("uploads/" . $id . "/parts"); 
    }
    //prepare params....
    $org_img = 'uploads/' . $name . "/" . $id . (substr($type,0,1) != "." ? "." . $type : $type);
    $dst_img = 'uploads/' . $id . "/parts/" . $nr .  (substr($type,0,1) != "." ? "." . $type : $type);
    $tmp_img = imagecreatetruecolor(200, 200);
    if ($type == ".jpg" or $type == "jpeg") {
        $src_img = imagecreatefromjpeg($org_img);
    }
    elseif ($type == ".png") {
        $src_img = imagecreatefrompng($org_img);
    }
    elseif ($type == ".gif") {
        $src_img = imagecreatefromgif($org_img);
    }
    else {
        exit;
    }
    $sX = ($nr-1)%3 * 200;          //// watch this question:
    $sY = floor(($nr-1)/3) * 200;   //// http://stackoverflow.com/questions/6325169/variable-has-unexpected-value
    imagecopy($tmp_img, $src_img, 0,0, $sX, $sY, 200, 200);
    if ($type == ".jpg" or $type == "jpeg") {
        imagejpeg($tmp_img, $dst_img,100);  // because of ini_set i dont get an error here
    }
    elseif ($type == ".png") {
        imagepng($tmp_img, $dst_img, 0);    //on these functions, I get the errors
    }
    else {
        imagegif($tmp_img, $dst_img);       //also here i get an error
    }
    imagedestroy($tmp_img);
}
  • 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-23T02:39:15+00:00Added an answer on May 23, 2026 at 2:39 am

    There is not too much to work from but sometimes when you use a process like you are PHP changes the image header to JFIF (JPEG) instead of GIF98a (GIF) so run a check on the header before you use imagecreatefrom….
    Hope this helps a little bit, maybe more code would help us all?

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

Sidebar

Related Questions

I've got a problem with Expression Web 3. Just installed Expression Studio trial form
I got a web application, the problem is that the text in the label
I've got a rather confusing problem. Web Service A - Called directly by Win32
Problem: (Solution at the end) I got a Silverlight App with-in a Web Project
I encounter a problem in my web program. I got a textarea in my
I've got problem sending an array of string as parameter to a web service
I've got a problem with a SOAP Web Reference that was generated by Visual
I have got a serious problem running our web app in some machines.. machines
i've got a problem i try to parce a web page which in UTF-8
I've got a problem with a web service which has an array or List

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.