最后我修改了 php 来调整上传图片的大小。我不知道我的 delphi 代码有什么问题。
<?php
$uploaddir = strval($_GET['dir']);
$newwidth = strval($_GET['newwidth']);
$newheight = strval($_GET['newheight']);
$uploadfile = $uploaddir . basename( $_FILES['file']['name']);
move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile);
$sourceProperties = getimagesize($uploadfile);
$fileNewName = $_FILES['file']['name'];
$imageType = $sourceProperties[2];
$imageResourceId = imagecreatefrompng($uploadfile);
$targetLayer = imageResize($imageResourceId,$sourceProperties[0],$sourceProperties[1],$newwidth,$newheight);
imagepng($targetLayer,$uploaddir. "thumb". $fileNewName);
move_uploaded_file($uploadfile, $uploaddir. $fileNewName. ".". "png");
function imageResize($imageResourceId,$width,$height,$twidth,$theigth) {
$targetWidth =$twidth;
$targetHeight =$theigth;
$targetLayer=imagecreatetruecolor($twidth,$theigth);
imagecopyresampled($targetLayer,$imageResourceId,0,0,0,0,$twidth,$theigth, $width,$height);
return $targetLayer;
}
?>