/67d2b231009cfc08ae0375eedcbe33ad.jpg /前面的文件名怎么不出来
<?php
// $fileInfo = $_FILES['myFile'];
function uploadFile($fileInfo, $flag = true, $allowExt = array('jpeg','jpg','png', 'gif'), $maxSize = 2097152, $uploadPath = 'upload'){
// 判断错误号
if ($fileInfo['error'] > 0) {
switch ($fileInfo['error']) {
case 1:
$mes = '超出配置文件';
break;
case 2:
$mes = '超出表单文件';
break;
case 3:
$mes = '部分文件上传';
break;
case 4:
$mes = '无上传的文件';
break;
case 6:
$mes = '无零时的文件';
break;
case 7:
case 8:
$mes = '系统错误';
break;
}
exit($mes);
}
$ext = pathinfo($fileInfo['name'], PATHINFO_EXTENSION);
/*
* $allowExt = array(
* 'jpeg',
* 'jpg',
* 'png',
* 'gif',
* 'wbmp'
* );
*/
if(!is_array($allowExt)){
exit('系统错误');
}
// 检测上传文件的类型
if (!in_array ($ext, $allowExt)) {
exit('非法文件类型');
}
// $maxSize = 2097152; // 默认值2M
// 检测上传文件的大小
if ($fileInfo['size'] > $maxSize) {
exit('上传文件过大');
}
// 检测图片是否为真实类型
// $flag=true;
if ($flag) {
if (! getimagesize($fileInfo['tmp_name'] )) {
exit('图片格式不对');
}
}
// 检查文件是否为HTTP POST方式上传
if (! is_uploaded_file ( $fileInfo['tmp_name'] )) {
exit ('文件不是通过HTTP POST方式上传');
}
// $uploadedPath = 'uploads';
if (! file_exists($uploadPath)) {
mkdir($uploadPath, 0777, true);
chmod($uploadPath, 0777);
}
$uniName = md5 ( uniqid ( microtime (true), true)) . '.' . $ext;
$destination = $uploadpath. '/' . $uniName;
if (!@move_uploaded_file($fileInfo['tmp_name'], $destination)) {
exit('文件移动失败');
}
// echo '文件上传成功';
// return array(
// 'newName'=>$destination,
// 'size'=>$fileInfo['size'],
// 'type'=>$fileInfo['type'],
// );
return $destination;
}
显示结果:
/67d2b231009cfc08ae0375eedcbe33ad.jpg /前面的文件名怎么不出来