• 上传文件


    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代码

    <form method="post" enctype="muitipart/form-data" target="hiddenwin" id="ajaxForm" action="{{url('home/cateDoc/dotest')}}" class="form-condensed">
                                    <table class="table table-form">
                                        <tbody>
                                            <tr>
                                                <th>文档类型名称:</th>
                                                <td><div class="required required-wrapper"></div>
                                                     <input type="file" name="myfile" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td></td>
                                                <td>
                                                <button type="submit" id="submit" class="btn btn-submit btn-primary">
                                                    保存
                                                </button><a href="javascript:history.go(-1);" class="btn btn-back">返回</a>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </form>
  • 相关阅读:
    iOS故事板下使用代码跳转页面
    眼见不一定为实
    UITableView
    iOS 备忘录
    统计代码行数
    iOS - 图片合成
    UI 素材
    xcode中xib使用小技巧
    svn不能提交静态库解决方案
    在webSocket中获取shiro报错
  • 原文地址:https://www.cnblogs.com/yuwensong/p/4832955.html
Copyright © 2020-2023  润新知