求救:php 上传图片时,获取图片的大小??
<?phpif(isset($_POST['uploadButton'])){//echo'ddddd';echoimagecreatefromjpeg($_FILES[...
<?php
if (isset ($_POST['uploadButton']))
{
//echo 'ddddd';
echo imagecreatefromjpeg($_FILES['file_upload']['name']);
print_r(getimagesize($_FILES['file_upload']['name']));
print_r($_FILES['file_upload']);
}
?>
<form action="1.php" method="post" enctype="multipart/form-data">
<input type="file" name="file_upload">
<input type="submit" value="upload" name="uploadButton">
</form>
目的:图片没有保存到指定的文件夹之前,能够获取图片的尺寸 展开
if (isset ($_POST['uploadButton']))
{
//echo 'ddddd';
echo imagecreatefromjpeg($_FILES['file_upload']['name']);
print_r(getimagesize($_FILES['file_upload']['name']));
print_r($_FILES['file_upload']);
}
?>
<form action="1.php" method="post" enctype="multipart/form-data">
<input type="file" name="file_upload">
<input type="submit" value="upload" name="uploadButton">
</form>
目的:图片没有保存到指定的文件夹之前,能够获取图片的尺寸 展开
3个回答
展开全部
function upload($path,$photo,$zoom=false){
$uploaddir = $path;
$piece = explode('.',$photo['name']);
$uploadfile = $uploaddir . md5($piece[0]).'.'.$piece[1];
$result = move_uploaded_file($photo['tmp_name'], $uploadfile);
if(!$result){
return false;
}
if($zoom){
list($width_orig, $height_orig) = getimagesize($uploadfile);
if ($width_orig!=61||$height_orig!=61) {
$image_p = imagecreatetruecolor(61, 61);
if($piece[1]=="jpg"||$piece[1]=="jpeg"){
$image = imagecreatefromjpeg($uploadfile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 61, 61, $width_orig, $height_orig);
imagejpeg($image_p,$uploadfile);
}else if($piece[1]=="gif"){
$image = imagecreatefromgif($uploadfile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 61, 61, $width_orig, $height_orig);
imagegif($image_p,$uploadfile);
}
}
}
return basename($uploadfile);
}
$uploaddir = $path;
$piece = explode('.',$photo['name']);
$uploadfile = $uploaddir . md5($piece[0]).'.'.$piece[1];
$result = move_uploaded_file($photo['tmp_name'], $uploadfile);
if(!$result){
return false;
}
if($zoom){
list($width_orig, $height_orig) = getimagesize($uploadfile);
if ($width_orig!=61||$height_orig!=61) {
$image_p = imagecreatetruecolor(61, 61);
if($piece[1]=="jpg"||$piece[1]=="jpeg"){
$image = imagecreatefromjpeg($uploadfile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 61, 61, $width_orig, $height_orig);
imagejpeg($image_p,$uploadfile);
}else if($piece[1]=="gif"){
$image = imagecreatefromgif($uploadfile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, 61, 61, $width_orig, $height_orig);
imagegif($image_p,$uploadfile);
}
}
}
return basename($uploadfile);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Unforgiveness 说的没错
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询