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
Release: 2016-07-13 09:48:14
Original
1017 people have browsed it

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);
......
Copy after login

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...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template