📅  最后修改于: 2023-12-03 15:27:52.648000             🧑  作者: Mango
该程序是一个基于PHP语言的图片上传脚本。其主要功能是将用户上传的图片保存到服务器并在蛋糕中显示。
//上传图片
if(isset($_FILES['file'])){
$file = $_FILES['file'];
$fileName = $_FILES['file']['name'];
$fileTmpName = $_FILES['file']['tmp_name'];
$fileSize = $_FILES['file']['size'];
$fileError = $_FILES['file']['error'];
$fileType = $_FILES['file']['type'];
$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));
$allowed = array('jpg', 'jpeg', 'png');
//判断是否是允许上传的图片类型
if(in_array($fileActualExt, $allowed)){
//上传图片的目录
$fileDestination = 'uploads/' . $fileName;
move_uploaded_file($fileTmpName, $fileDestination);
header("Location: index.php?uploadsuccess");
} else {
echo "You can't upload files of this type!";
}
}