This is thinkphp's upload settings, namely, file name, root directory and upload directory settings.
$upload->saveName = date('YmdHis').mt_rand(1000,9999).$customerid; $upload->rootPath = "./"; $upload->savePath = 'Upload/Home/headpic/'.customerid.'/'; //Set the attachment upload directory
As you can see, the directory I set up is spliced with the specified directory and user id.
The path actually generated has an additional layer of date.
The problem has been solved.
As shown in the figure, Upload.class.php uploads class files under LibraryThink. Some screenshots are as follows.
There is a default setting that opens subdirectories and file names. Pit
Set the controller to false
Also, a friendly reminder! ! !
RootPath is very important! ! If you are using the default Uploads to upload folders and are in the root directory, you can ignore this operation. However, if your upload file storage directory is another file name under the root directory, then the rootPath needs to be set as above. According to your requirements, modify rootPath and savePath.
The file upload class of tp will create a new subName directory under the savepath directory and set $upload->saveName to null
Tp source code
Subname' = > array ('date',' y-m-d'),//subdirectory creation method, - function name, - parameter, multiple parameters use array
SubName defaults to date, setting $upload->subName = “”; Just do it