php resize image on upload

后端 未结 12 1476
别跟我提以往
别跟我提以往 2020-11-27 04:09

I got a form where the user is inserting some data and also uploading an image.

To deal with the image, I got the following code:

define(\"MAX_SIZE\"         


        
12条回答
  •  情书的邮戳
    2020-11-27 04:41

    " method="post" enctype="multipart/form-data" id="something" class="uniForm">

    "; imagejpeg($tn, $save, 100) ; //thumbnail image making part $save = "images/thumb/" . $imagepath; //This is the new file you saving $file = "images/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 150; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; //echo "Thumbnail: "; imagejpeg($tn, $save, 100) ; } else{ echo "File is not image"; } } } ?>

提交回复
热议问题