In thinkphp, how does one process uploaded files? in thinkphp, how does one process uploaded files? that is, all files must be processed. I made a website to upload all the files including images, txt files, doc files, and videos. How can I upload and insert data to a database? $ MM (& quot; file & quot;); $ _ cleanarray (); if (! Empty ($ _ FILES) {& nbsp; $ I thinkphp
How to process uploaded files in thinkphp, that is, to process all files. I made a website to upload all the files including images, txt files, doc files, and videos. How can I upload and insert data to a database?
$ M = M ("file ");
// $ _ Clean = array ();
If (! Empty ($ _ FILES )){
$ Im = $ this-> _ upload ();
$ _ POST ["filename"] = $ im;
$ _ POST ["uptime"] = time ();
}
$ N = $ m-> add ();
If ($ n ){
$ Str = "added successfully ";
} Else {
$ Str = "failed to add ";
}
$ This-> assign ("str", $ str );
$ This-> display ("upload ");
}
// File Upload
Protected function _ upload (){
Import ("@. ORG. UploadFile ");
$ Upload = new UploadFile ();
// Set the size of the uploaded file
$ Upload-> maxSize = 3292200;
// Set the Upload file type
$ Upload-> allowExts = explode (',', 'jpg, gif, png, jpeg, pjpeg, bmp, doc, rar, txt ');
// Set the attachment Upload Directory
$ Upload-> savePath = './Public/upload /';
// Set file Upload rules
$ Upload-> saveRule = uniqid;
If (! $ Upload-> upload ()){
// Capture Upload exceptions
$ This-> error ($ upload-> getErrorMsg ());
} Else {
// Obtain the information of the successfully uploaded File
$ UploadList = $ upload-> getUploadFileInfo ();
// Import ("@. ORG. Image ");
// Add a watermark to the m _ thumbnail. Image: water ('original filename ', 'watermark Image address ')
/* Image: water ($ uploadList [0] ['savepath'].'m _'. $ uploadList [0] ['savename'], '/thinkphp_2.20.full_with_extend/Examples/File/Tpl/default/Public/Images/logo2.png ');*/
Return $ uploadList [0] ['savename'];
}
} I cannot handle this.
------ Solution --------------------
Http://thinkphp1.cn/Manual/170
------ Solution --------------------
Isn't thinkphp a demo?
------ Solution --------------------
$ Upload-> savePath = './Public/upload /';
Change
$ Upload-> savePath = './upload /';
Try it