사이트에서이 스크립트를 본 후 내 코드에서 작동 시키려고했습니다. 하지만 이미지를 업로드 할 때 나는 아무 것도 출력하지 않고 이미지의 크기가 조정되지 않습니다. 누군가 내가 잘못한 것을 볼 수 있기를 바랍니다.PHP : 크기 조정 이미지
class.imageResizer.php
<?php
class ImgResizer {
var $originalFile = '$newName';
function ImgResizer($originalFile = '$newName') {
$this -> originalFile = $originalFile;
}
function resize($newWidth, $targetFile) {
if (empty($newWidth) || empty($targetFile)) {
return false;
}
$src = imagecreatefromjpeg($this -> originalFile);
list($width, $height) = getimagesize($this -> originalFile);
$newHeight = ($height/$width) * $newWidth;
$tmp = imagecreatetruecolor($newWidth, $newHeight);
imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
if (file_exists($targetFile)) {
unlink($targetFile);
}
imagejpeg($tmp, $targetFile, 95);
}
}
?>
$ newName로는 = 업 로더
//If no errors do this
if (isset($_POST['Submit']) && !$errors)
{
//Resizing the picture
include 'class.imageResizer.php';
$work = new ImgResizer('users/$username/$imageName');
$work -> resize(400, 'users/$username/$username-246.$extension');
$sql = "UPDATE members SET user_pic='http://www.something.net/$newName' WHERE username='$username'";
$_SESSION['user_pic'] = $newName;
$result = mysql_query($sql);
mysql_close($conn);
}
사용자/theusername/theusername.theextension
$ 참고 ImageName = theusername합니다. 확장 물
아, 내 문제가 있습니다. 고마워! – Kaizokupuffball