<?php
|
$file = $_FILES["file"];
|
//echo $file["name"];
|
//exit;
|
//检证传进文件类型
|
$allowType=array("png", "gif", "jpg", "jpeg");
|
$imgType = strtolower(substr($file["name"],strrpos($file["name"],'.')+1));
|
if(!in_array($imgType, $allowType)){
|
echo "非图片文件";
|
exit;
|
}
|
//检验文件大小
|
$fileSize = $file["size"]; //图片大小
|
$maxsize=2000 * 1024; //最大文件大小
|
if($fileSize > $maxsize){
|
echo "文件过大";
|
exit;
|
}
|
|
//修改文件名 以时间戳命名
|
$randname=date("Y").date("m").date("d").date("H").date("i").date("s").rand(100, 999).".".$imgType;
|
//检验文件是否是通过HTTP POST上传
|
if(is_uploaded_file($file["tmp_name"])){
|
$filepath = '../UserPhoto/';//保存文件路径
|
move_uploaded_file($file["tmp_name"],$filepath.$randname);
|
$randname1 = "https://api.966120.com.cn/UserPhoto/".$randname;
|
$return = array(
|
"SnsImg" => $randname1,
|
"result" => "1"
|
);
|
echo $randname1;
|
}else{
|
exit;
|
}
|
?>
|