namespace home \ controller;
use think \ controller;
class indexcontroller extends controller {
 function index () {
   $this->display ();
 public function upload () {
  $upload=new \ think \ upload ();//Instantiate the upload class
  $upload->maxsize=3145728;//Set attachment upload size
  $upload->exts=array ("jpg", "gif", "png", "jpeg");//Set attachment upload type
  $upload->rootpath="./uploads/";//Set the attachment upload root directory
  $upload->savepath="";//Set attachment upload (sub) directory
  //upload files
  $info=$upload->upload ();
  print_r ($info);exit;
  if (! $info) {//upload error prompt error message
  $this->error ($upload->geterror ());
  } else {//upload successfully
  $this->success ("Upload succeeded!");


In the view, create a folder index with the same name as the controller, and then create an html index file with the same name as the method, which is omitted here.

  • Previous Sixty-five of Manipulating Data in ASPNET 20: Creating New Stored Procedures in TableAdapters
  • Next WEB front-end development framework Bootstrap3 VS Foundation5