我这里有一个代码可以生成已调整大小的图像,但它会生成一个固定名称$url = 'destination.jpg';
所以这是我的代码,而不是生成一个固定的名称,我怎么能将图像名称更改为随机数字和字母。例如$url = 'wy3vu45.jpg'
if ($_POST) {
if ($_FILES["file"]["error"] > 0) {
$error = $_FILES["file"]["error"];
}
else if (($_FILES["file"]["type"] == "image/gif") ||
($_FILES["file"]["type"] == "image/jpeg") ||
($_FILES["file"]["type"] == "image/png") ||
($_FILES["file"]["type"] == "image/pjpeg")) {
$url = 'destination .jpg';
$filename = compress_image($_FILES["file"]["tmp_name"], $url, 50);
$buffer = file_get_contents($url);
/* Force download dialog... */
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
/* Don't allow caching... */
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
/* Set data type, size and filename */
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . strlen($buffer));
header("Content-Disposition: attachment; filename=$url");
/* Send our file... */
echo $buffer;
}else {
$error = "Uploaded image should be jpg or gif or png";
}
}