1.开启php_fileinfo.dll 拓展(php.ini)
2. php端代码
public function dotest(){ $file = Input::file('myfile'); if($file -> isValid()){ $clientName = $file -> getClientOriginalName(); $tmpName = $file ->getFileName(); // 缓存在tmp文件夹中的文件名 $realPath = $file -> getRealPath(); //获取真实绝对路径 $extension = $file -> getClientOriginalExtension(); //上传文件的后缀\ $mimeTye = $file -> getMimeType(); $newName = md5(date('ymdhis').$clientName).".".$extension; //重新组装文件名 $path = $file -> move('../storage/app/uploads',$newName); } }
3.html代码