💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
> 下面是一个简单的上传头像的演示 ~~~ //载入扩展 extend('UploadFile.class.php'); //实例化上传类库,允许上传类型(jpg,png,gif),限制上传大小200kb $upload = new \Upload(array('jpg','png','gif'),(1024*200),array('image/jpg','image/png','image/gif')); //也可以不进行限制 //$upload = new \Upload(); //判断客户端是否有上传file[head],如果是表单可以写<input type="file" name="head"> if (!empty($_FILES['head'])) { //上传并保存到指定目录,这里需要自己手动预先在Web目录中创建好Upload基础目录,否则无法上传 if (!$upload->upload('Upload/head')) { //失败反馈原因 return $upload->getErrorMsg(); } //上传成功返回路径 $headInfos = $upload->getUploadFileInfo(); return $headInfos[0]['savepath'] . $headInfos[0]['savename']; } ~~~ ### 属性介绍 ~~~ //载入扩展 extend('UploadFile.class.php'); //实例化上传类库 $upload = new \Upload(); //设置允许的后缀 $upload->allowExts = array('jpg','png','gif'); // 设置允许的文件类型 $upload->allowTypes = array('image/jpg','image/png','image/gif'); //设置限制上传大小,单位为b $upload->maxSize = 1024 * 200; //设置保存路径 $upload->savePath = "Upload/head"; //上传并保存 if (!$upload->upload()) { //失败反馈原因 return $upload->getErrorMsg(); } //上传成功返回路径 $headInfos = $upload->getUploadFileInfo(); return $headInfos[0]['savepath'] . $headInfos[0]['savename']; ~~~