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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:37:57+00:00 2026-06-13T19:37:57+00:00

heres my page. my question is why the form returns blank page when i

  • 0

heres my page. my question is why the form returns blank page when i upload a picture. it worked fine till i added the last switch statement. the one to create image. (imagejpeg function) it works when i do without the switch statement. but after i add switch statement the form disappears. so my question is , what am i doing wrong with the switch statement ? or with the code in total?

    $imageFile = $_FILES['image']['tmp_name']; 
    $filename = basename( $_FILES['image']['name']);

    list($width, $height) = getimagesize($imageFile);
    $picture = getimagesize($imageFile);

    if ($width >= $height) 
    {
        $orig_w = 500;
        $orig_h =($height/$width)*$orig_w;
    } else
    {
        $orig_h = 500;
        $orig_w = ($width/$height)*$orig_h;
    }

    $picture['format'] = strtolower(preg_replace('/^.*?\//', '', $picture['mime']));

    switch( $picture['format'] ) {
    case 'jpg':
    case 'jpeg': 
        $src = imagecreatefromjpeg($imageFile);
    break;
    case 'png':
        $src = imagecreatefrompng($imageFile);
    break;
    case 'gif':
        $src = imagecreatefromgif($imageFile);
    break;
    default:
        echo "unsproted format";
    break;
}

    $tmp = imagecreatetruecolor($orig_w, $orig_h);
    imagecopyresampled($tmp, $src , 0,0,0,0, $orig_w,$orig_h, $width, $height);

    switch( $picture['format'] ) {
        case 'jpg':
        case 'jpeg':
            return imagejpeg($tmp, $folder.$filename, 100);
        break;
        case 'png':
            return imagepng($tmp, $folder.$filename);
        break;
        case 'gif':
            return imagegif($tmp, $folder.$filename);
        break;
        default:
            echo "unsproted format";
        break;
    }

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

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<h1 > php image upload form </h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
    <p>
        <label for="image" > Image: </label>
        <input type="file" name="image" id="image" /> <br/>
    </p>
    <p>
        <input type="submit" name="submit" value="upload image" />
    </p>
</form>
</body>
</html>
  • 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-13T19:37:58+00:00Added an answer on June 13, 2026 at 7:37 pm

    i did it. apparently i couldnt figure out what was wrong with the switch statement (im still a noob in php) hehe.. but replaced the switch statement with :

    $xtention = explode(".",$filename); 
    
    if ($xtention[1] == 'jpg' || $xtention[1] == 'jpeg' ) {
            imagejpeg($tmp, $folder.$filename, 100);
        }
        elseif ($xtention[1] == 'png') {
            imagepng($tmp, $folder.$filename);
        }
        elseif ($xtention[1] == 'gif') {
            imagegif($tmp, $folder.$filename);
        }
        else {
            echo "unsproted format";
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is, how can I not display a form on a page by
So I asked a question earlier about retrieving high scores form an html page
The page in question is featured here: http://www.allwebcafe.com/news/news-article.php?id=78 For some reason, when a user
I wasn't sure what to title this question. Here's my goal: On page one,
http://www.designobvio.us/GoldGrid2/ heres a sample page. middle of the screen there will be the content
I have a form for updating user data. It posts to this page: <?php
I have a JQuery modal popup form on a classic ASP page. It's set
All, I have an HTML page that contains a form. When the user completes
Here's the page in question: http://www.lukaspleva.com/MoneyThink/NationalAdmin.php If you go to that page, you'll see
I have a form which automatically refreshes the page on submit, I have tried

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.