ThinkPHP3.2 simple File Upload method,
This article describes thinkPHP3.2 simple File Upload method. We will share this with you for your reference. The details are as follows:
IndexController. class. php:
<? Phpnamespace 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 the attachment upload size $ upload-> exts = array ('jpg ', 'gif', 'png', 'jpeg '); // set the attachment upload type $ upload-> rootPath = '. /Uploads/'; // sets the root directory for uploading attachments $ upload-> savePath = ''; // sets the attachment upload (sub) Directory // Uploads files $ info = $ Upload-> upload (); print_r ($ info); exit; if (! $ Info) {// upload error message $ this-> error ($ upload-> getError ());} else {// upload successful $ this-> success ('upload successful! ') ;}}?>
Index.html:
Create a folder Index with the same name as the controller in the view and create an html index file with the same name as the method. This is omitted here.
Supplement: The editor recommends a php formatting and formatting typographical tool on this site to help you typeset code in future PHP programming:
Php code online formatting and beautification tools:Http://tools.jb51.net/code/phpformat