我是 php 新手,我已经下载了图片库的免费源代码。它有管理员帐户,您可以在其上上传图像。现在,当我上传图片时,它会生成随机图片标题,如数字“4849404”。我希望它为每个图像分配一个特定的标题。我怎样才能做到这一点?如果我没记错的话,我认为这是图像标题的行:
$RandomNumber = rand(0, 9999999999); // We need same random name for both files.
// some information about image we need later.
$ImageName = strtolower($_FILES['ImageFile']['name']);
$ImageSize = $_FILES['ImageFile']['size'];
$TempSrc = $_FILES['ImageFile']['tmp_name'];
$ImageType = $_FILES['ImageFile']['type'];
$process = true;
//Validate file + create image from uploaded file.
switch(strtolower($ImageType))
{
case 'image/png':
$CreatedImage = imagecreatefrompng($_FILES['ImageFile']['tmp_name']);
break;
case 'image/gif':
$CreatedImage = imagecreatefromgif($_FILES['ImageFile']['tmp_name']);
break;
case 'image/jpeg':
$CreatedImage = imagecreatefromjpeg($_FILES['ImageFile']['tmp_name']);
break;
default:
die('Unsupported File!'); //output error
}
//get Image Size
list($CurWidth,$CurHeight)=getimagesize($TempSrc);
//get file extension, this will be added after random name
$ImageExt = substr($ImageName, strrpos($ImageName, '.'));
$ImageExt = str_replace('.','',$ImageExt);
$BigImageMaxWidth = $CurWidth;
$BigImageMaxHeight = $CurHeight;
//Set the Destination Image path with Random Name
$thumb_DestRandImageName = $Thumb.$RandomNumber.'.'.$ImageExt; //Thumb name
$DestRandImageName = $DestinationDirectory.$RandomNumber.'.'.$ImageExt; //Name for Big Image
//Resize image to our Specified Size by calling our resizeImage function.
if(resizeImage($CurWidth,$CurHeight,$BigImageMaxWidth,$BigImageMaxHeight,$DestRandImageName,$CreatedImage))
{
//Create Thumbnail for the Image
resizeImage($CurWidth,$CurHeight,$ThumbMaxWidth,$ThumbMaxHeight,$thumb_DestRandImageName,$CreatedImage);
//respond with our images
echo '<table width="100%" border="0" cellpadding="4" cellspacing="0">
<tr><td align="center"><img src="gallery/'.$RandomNumber.'.'.$ImageExt.'" alt="Resized Image"></td></tr></table>';
}else{
die('Resize Error'); //output error
}
}