zoukankan      html  css  js  c++  java
  • laravel文件上传

            $file = Request::file('photo');//文件
            $name = input::get('name');//其他属性值
            $allowed_extensions = ["png", "jpg", "gif"];
            if ($file->getClientOriginalExtension() && !in_array($file->getClientOriginalExtension(), $allowed_extensions)) {
                return ['error' => 'You may only upload png, jpg or gif.'];
            }
            $destinationPath = 'storage/uploads/'; //public 文件夹下面建 storage/uploads 文件夹
            $extension = $file->getClientOriginalExtension();
            $fileName = str_random(10).'.'.$extension;
            $file->move($destinationPath, $fileName);
            $filePath = asset($destinationPath.$fileName);
            $info=DB::insert('insert into photo(pname,photo) VALUES (?,?)',[$name,$filePath]);//入库
              if($info){
               return Redirect('/show');
              }else{
                  echo "no";
              }
  • 相关阅读:
    ebs R12 支持IE11
    reloc: Permission denied
    3.23考试小记
    3.21考试小记
    3.20考试小记
    3.17考试小记
    3.15考试小记
    3.13考试小记
    3.12考试小记
    3.10考试小记
  • 原文地址:https://www.cnblogs.com/zmdComeOn/p/10250635.html
Copyright © 2011-2022 走看看