Blogger Information
Blog 1
fans 0
comment 1
visits 716
Related recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP
阿东的博客
Original
717 people have browsed it

/*

    *文件上传处理  

   */

public function upload(Request $request)

{

// 1、获取上传文件

$file = $request->file('file_upload');

// return $file;

// 2、判断上传文件的有效性

if($file->isValid()){

//获取文件的后缀名

$ext = $file->getClientOriginalExtension();

// return $ext;

//生成新的文件名

$newfilename = md5(date('YmdHis').rand(1000,9999).uniqid()).'.'.$ext;

// 移动文件到指定位置

// return $newfilename;

$res = $file->move(public_path().'/upload',$newfilename);

//将文件上传的位置返回给客户端

return '/upload/'.$newfilename;

}

}


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
1 comments
CHN - Winter.J 2019-02-14 17:40:48
加油
1 floor
Author's latest blog post
  • PHP
    2018-03-15 11:52:27