PHP 怎么使用put 50
1个回答
展开全部
//接收上传的文件
foreach($_FILES as $file)
{
$tempFileName = $file['tmp_name'];//上传文件的临时路径
}
/把图片移动到服务器制定路径
$img = '/var/www/html/picture/test.jpg';
move_uploaded_file($tempFileName, $img);
//缩放比例
$ratio = 0.5;
//修改尺寸 至于各个函数是干嘛的,google一下吧
$imagedata = getimagesize($img);
$olgWidth = $imagedata[0];
$oldHeight = $imagedata[1];
$newWidth = $olgWidth * $ratio;
$newHeight = $oldHeight * $ratio;
$image = imagecreatefromjpeg($img);
$thumb = imagecreatetruecolor ($newWidth, $newHeight);
imagecopyresized ($thumb, $image, 0, 0, 0, 0, $newWidth, $newHeight, $olgWidth, $oldHeight);
imagejpeg($thumb, $img);
imagedestroy($thumb);
imagedestroy($image);
foreach($_FILES as $file)
{
$tempFileName = $file['tmp_name'];//上传文件的临时路径
}
/把图片移动到服务器制定路径
$img = '/var/www/html/picture/test.jpg';
move_uploaded_file($tempFileName, $img);
//缩放比例
$ratio = 0.5;
//修改尺寸 至于各个函数是干嘛的,google一下吧
$imagedata = getimagesize($img);
$olgWidth = $imagedata[0];
$oldHeight = $imagedata[1];
$newWidth = $olgWidth * $ratio;
$newHeight = $oldHeight * $ratio;
$image = imagecreatefromjpeg($img);
$thumb = imagecreatetruecolor ($newWidth, $newHeight);
imagecopyresized ($thumb, $image, 0, 0, 0, 0, $newWidth, $newHeight, $olgWidth, $oldHeight);
imagejpeg($thumb, $img);
imagedestroy($thumb);
imagedestroy($image);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询