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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:37:14+00:00 2026-06-17T12:37:14+00:00

So I have an image upload script. It uploads the image and saves it

  • 0

So I have an image upload script.
It uploads the image and saves it to the space on the server.
What I can’t seem to get my head around is say, when the user uploads a .png, by the time it saves on my server i want it to be a jpg.

Can anyone help with this, and please don’t just direct me to another question as I havent had anything work yet. Here is an example of my code.

$name = addslashes($_FILES['image']['name']);
$ext = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION); 
$size = $_FILES['image']['size'];
$temp = $_FILES ['image']['tmp_name'];
$error = $_FILES ['image']['error'];

if ($error > 0)
    die("Error uploading file! Code $error.");
else


if ($password == "" || $size > 2000000) {
    move_uploaded_file($temp, $images.$name);   
    mysql_query("INSERT INTO image_approval VALUES ('','$description','','$images$name','',NOW())");

    echo "Upload complete!";
    }else{
echo "Error uploading file";
    }
  • 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-17T12:37:15+00:00Added an answer on June 17, 2026 at 12:37 pm

    Using GD, and assuming $images is the directory where you store your images (with ending slash), and $name – the file name of the original image:

    $destinationPath = $images . basename($name, $ext) . '.jpg';
    $source = imagecreatefrompng($images . $name);
    imagejpeg($source, $destinationPath, 75);
    imagedestroy($source);
    

    Or with Imagick:

    $image = new Imagick($images . $name);
    $image->writeImage($destinationPath);
    $image->destroy();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script where a user can upload an image. This image
Let's say i have an image uploader script, i want to prevent the upload
i currently have an upload script which saves the image names in a database,
I have a script that uploads an image using JavaScript, as seen here .
BACKGROUND I have a script to upload an image. One to keep the original
I have a small python cgi script that accepts an image upload from the
I have a ajax image upload script which i found here http://www.fengcool.com/2009/06/ajax-form-upload-local-image-file-without-refresh/ The problem
I wrote a script for uploading an image to my server. Users can use
Hi I have an upload script that uploads images to a file, but I
I have an HTML5 app that saves the canvas image to the server and

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.