Home  >  Article  >  Backend Development  >  yii upload file or image example_PHP tutorial

yii upload file or image example_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:34:53818browse

1.test.php

Copy code The code is as follows:








'/test/upload/'Change it to your corresponding address.
2.TestController.php
Copy code The code is as follows:

public function actionUpload( )
{

$dir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : '';
$image = CUploadedFile::getInstanceByName('file' ; {
                             mkdir($dir);                                                                                                                                                                                                                                                             🎜>
$status = $image->saveAs($name,true);
//Save the file
if ($status) {
echo 'success';
}else {
                 echo 'fail';
Visit http://www.ttlsa.com/test/test and upload your files. If successes appears, it means success.





http://www.bkjia.com/PHPjc/748159.html

www.bkjia.com
true
http: //www.bkjia.com/PHPjc/748159.htmlTechArticle


1.test.php Copy the code as follows: body form action="?php echo $this-createUrl(' /test/upload/');?" method="post" enctype="multipart/form-data" input type="file" name="file"/ inp...

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