recently looked at Yii,yii has a way to upload pictures with it. Simple code to paste. Divided into two pieces, the first block of view:test.php. The second block is controller:TestController.php
The 1.test.php code is as follows: <body> <form action= "<?php echo $this->createurl ('/test/upload/');? > "method=" Post "enctype=" Multipart/form-data "> <input type=" file "name=" file "/> <input" type= " Name= "dir" value= "test"/> <input type= "Submit" value= "Upload Image"/> </form> </body> '/test/ upload/' to your corresponding address. 2.testcontroller.php Code as follows: public Function actionupload () { $dir = isset ($_request[' dir '])? $_request[' dir ']: '; $image = cuploadedfile::getinstancebyname (' file '); $dir =yii::getpathofalias (' Webroot '). ' /images/'. $dir. '/'; //upload directory if (!is_dir ($dir)) { &NB Sp mkdir ($dir); //directory does not exist then create { $name = $dir. $image->name; &NBSp FileName absolute path $status = $image->saveas ($name, True); // Save file if ($status) { echo ' success '; &N Bsp }else { echo ' fail '; } } 3. Test Access Http://www.ttlsa.com/test/test, upload your file. If there is a succes, the explanation is successful.