Home >Backend Development >PHP Tutorial >Yii gets the suffix name of the uploaded file_PHP tutorial

Yii gets the suffix name of the uploaded file_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:48:141045browse

Yii gets the suffix name of the uploaded file

Yii gets the suffix name of the uploaded file, mainly using the getExtensionName() method in the CUploadedFile class, for example:

<?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);
......

Articles you may be interested in

  • Yii framework module development analysis
  • Summary of how to use database transactions in Yii
  • Yii Action method skills
  • How to store and rename uploaded files by date in fckeditor uploaded files
  • Detailed analysis and explanation of yii framework directory structure
  • Yii framework cache knowledge summary
  • Yii controller action parameter binding processing
  • How to configure the default controller and action in the yii framework

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1024332.htmlTechArticleYii gets the suffix name of the uploaded file Yii gets the suffix name of the uploaded file, mainly using getExtensionName( in the CUploadedFile class ) method, for example: ?php...$form-image=CUploadedFile::ge...
Statement:
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