17 lines
		
	
	
		
			478 B
		
	
	
	
		
			PHP
		
	
	
		
		
			
		
	
	
			17 lines
		
	
	
		
			478 B
		
	
	
	
		
			PHP
		
	
	
| 
								 | 
							
								<?php
							 | 
						||
| 
								 | 
							
								namespace app\service;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								use think\file\UploadedFile;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								class File
							 | 
						||
| 
								 | 
							
								{
							 | 
						||
| 
								 | 
							
								    //上传文件移动到上传文件夹
							 | 
						||
| 
								 | 
							
								    public static function move(UploadedFile $file)
							 | 
						||
| 
								 | 
							
								    {
							 | 
						||
| 
								 | 
							
								        $upload_path = 'uploads/' . date('Ymd');
							 | 
						||
| 
								 | 
							
								        $path = app()->getRootPath() . $upload_path;
							 | 
						||
| 
								 | 
							
								        $filename = uniqid() . '.' . $file->extension();
							 | 
						||
| 
								 | 
							
								        $upload_filename = '/' . $upload_path . '/' . $filename;
							 | 
						||
| 
								 | 
							
								        return [$file->move($path, $filename), $file, $upload_filename];
							 | 
						||
| 
								 | 
							
								    }
							 | 
						||
| 
								 | 
							
								}
							 |