You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
717 B

<?php
header("Access-Control-Allow-Origin: *"); //解决跨域
header('Access-Control-Allow-Methods:post');// 响应类型
date_default_timezone_set('PRC');//获取当前时间
$month = date('Ym', time());//获取年月
define('BASE_PATH', str_replace('\\', '/', realpath(dirname(__FILE__).'/'))."/");
$dir = BASE_PATH."upload/".$month."/";//判断是否有对应的文件
$type = strtolower(substr($_FILES["file"]["name"],strrpos($_FILES["file"]["name"],'.')+1));
$rename = date("Y").date("m").date("d").date("H").date("i").date("s").rand(100, 999).".".$type;
$arr = array(
'code' => 0,//返回状态
'msg'=> '',//提示消息
'data' =>array(//文件链接
'src' => "/upload/".$month."/".$rename