Home > php教程 > php手册 > Yii获取上传文件的后缀名

Yii获取上传文件的后缀名

WBOY
Release: 2016-06-13 08:59:28
Original
1102 people have browsed it

Yii获取上传文件的后缀名

Yii获取上传文件的后缀名,主要是用CUploadedFile类中的getExtensionName()方法,例如:

<?php ......
$form->image=CUploadedFile::getInstance($form->model, 'image');
$randName=date('Ymdhis').rand(100,999).'.'.$form->model->image->getExtensionName();
$form->model->image->saveAs(Yii::app()->basePath.'/../upload/'.$randName);
......
Copy after login

您可能感兴趣的文章

  • Yii framework框架之模块开发分析
  • Yii中的数据库事务的使用方法小结
  • Yii 动作方法技巧
  • fckeditor上传文件按日期存放及重命名上传文件的方法
  • yii框架目录结构详细分析说明
  • yii框架缓存知识总结
  • Yii控制器动作参数绑定处理
  • yii框架如何配置默认controller与action
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template