Helper_uploader encapsulates a number of actions for uploading files
Existsfile () determines whether an uploaded object of the specified name exists
File () Gets the Files object
IsValid () Determine if the file object conforms to the check condition
Move () Moves the file object to the specified directory
Usage:
functionActionimportxls () {if(Request_is_post ()) {$uploader=NewHelper_uploader (); if($uploader->existsfile (' Mubanxls ')){ if($uploader-file(' Mubanxls ')->isvalid (' xls ', 10485760)) {//10M Set_time_limit(0); $uploadtmp _dir=index_dir. '/_tmp1010/uploadtmp/'; Helper_filesys:: Mkdirs ($uploadtmp _dir); $filenamebase=Date(' Ymd-his ').$this->_login_user[' Parent_uid '. xls; $filename=$uploadtmp _dir.$filenamebase; $uploader-file(' Mubanxls ')->move ($filename); //Analysis//return $this->_redirect (url ('/importxlshelper ', array (' filename ' = = $filenamebase, ' Use_sku_for_ Imgshow ' =>request (' use_sku_for_imgshow '))); LXB 2013828
$this->actionimportxlshelper ($filenamebase, request (' Use_sku_for_imgshow ')); }Else{ $this->_view[' error ']= ' <div class= ' error ' > The file you uploaded is not properly formatted, must be in XLS format, or the file is too large! </div> "; } }Else{ $this->_view[' error ']= ' <div class= ' error ' > Please upload the file correctly! </div> "; } } }
Qeephp Helper_uploader Class