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

    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>
  • 相关阅读:
    Linux CentOS7 下设置tomcat 开机自启动
    MYSQL批量导入数据报:[Err] 2006
    HTML页面仿WORD样式
    /usr/bin/ld: cannot find -lxxx 问题
    Linux 重命名
    Linux mail
    cenos 7 mysql
    linux 解压与压缩
    python 字符串替换
    cpu相关信息(进程、线程、核...)
  • 原文地址:https://www.cnblogs.com/yuwensong/p/4832955.html
Copyright © 2011-2022 走看看