3.2.1我发现有又拍云的上传驱动,所以把上传函数改造了一下以便于一次配置后可以自动判断上传/*<br>
自动获取上传配置上传函数<br>
*/<br>
function filed($config='',$path=''){<br>
$Upload_type=C('upload_type');<br>
$upload_driver=C($Upload_type);<br>
if (!$config) {<br>
$config = array(<br>
'maxSize' => 3145728,<br>
'rootPath' => 'Upload',<br>
'savePath' => $path,<br>
'saveName' => 'time',<br>
'exts' => array('jpg', 'gif', 'png', 'jpeg'),<br>
'autoSub' => true,<br>
'subName' => array('date','Ymd'),<br>
'replace' => true,<br>
);<br>
}<br>
// 实例化上传类<br>
$upload = new \Think\Upload($config,$Upload_type,$upload_driver);<br>
$path?true:$upload->savePath='/';<br>
$info = $upload->upload(); // 上传文件 <br>
if(!$info) { <br>
$data['type']=0;<br>
$data['msg']=$upload->getError(); <br>
return $data; // 上传错误提示错误信息 <br>
}else{<br>
$request=array();<br>
foreach ($info as $key => $value) {<br>
$request[]=$value;<br>
}<br>
if ($Upload_type!=='Local') {<br>
for($i=0;$i<count></count>
$res[]='http://'.C('files_domain').'/'.$config['rootPath'].$request[$i]['savepath'].$request[$i]['savename'];<br>
}<br>
}else{<br>
for($i=0;$i<count></count>
$res[]=__ROOT__.'/'.$config['rootPath'].$request[$i]['savepath'].$request[$i]['savename'];<br>
}<br>
}<br>
$data['type']=1;<br>
$data['msg']=$res;<br>
return $data;<br>
}<br>
}
配置项增加<?php return array(<br />
'files_domain'=>'文件空间绑定域名',<br>
'upload_type'=>'Upyun',//或Local<br>
'upyun'=>array(<br>
'bucket'=>'空间名',<br>
'username'=>'用户名',<br>
'password'=>'密码',<br>
'host'=>'v0.api.upyun.com'<br>
),<br>
);<br>
?>
AD:真正免费,域名+虚机+企业邮箱=0元

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver CS6
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
