Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Image upload question

Explorer ,
Oct 18, 2012 Oct 18, 2012

Copy link to clipboard

Copied

Hi all,

I've got an image upload section for an admin page.  I've tried countless tutorials, but I just can't seem to get anything to work the way I want it to.  I'm trying to resize the uploaded image to a specific size (w=215; h=250) and maintain the transparency of the png file.  All I can get to work is a simple upload that does not resize.  So far I've got this:

$current_image=$_FILES['image']['name'];

$extension = substr(strrchr($current_image, '.'), 1);

if ($extension != "png")

{

die('Unknown extension');

}

$new_image = $current_image;

$destination="../../assets/subfolder/".$country."/".$new_image;

$action = copy($_FILES['image']['tmp_name'], $destination);

if (!$action)

{

die('File copy failed');

}else{

Can anyone please help me get this to resize and keep the transparency?  Or point me in the right direction where I can find a tutorial that I can get to work?

Thank you very much.,

TOPICS
Server side applications

Views

507
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 22, 2012 Oct 22, 2012

Copy link to clipboard

Copied

LATEST

My book, PHP Solutions, 2nd Edition, devotes an entire chapter to generating and uploading thumbnail images. It's not free, but it might help you if you're stuck.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines