【问题标题】:Laravel 4.2 upload images not working when install to web hostingLaravel 4.2 安装到虚拟主机时上传图片不起作用
【发布时间】:2015-07-12 03:58:57
【问题描述】:

它适用于 xampp(php artisan serve)。 我使用:

            $file =Input::file('img');

            $archivo = value(function() use ($file){
                $filename = str_random(34) . '.' . $file->getClientOriginalExtension();
                return strtolower($filename);
            });


            $destinationPath = 'public/uploads/';
            // Move file to generated folder
            $check = $file->move($destinationPath, $archivo);

当我使用虚拟目录安装到虚拟主机时(剪切 /public uri 并重写 index.php)

它不工作。

        $file =Input::file('img');
            //$fileName = $file->getClientOriginalName();
            $archivo = value(function() use ($file){
                $filename = str_random(34) . '.' . $file->getClientOriginalExtension();
                return strtolower($filename);
            });
            //var_dump($archivo);

            $destinationPath = 'uploads/';
            // Move file to generated folder
            $check = $file->move($destinationPath, $archivo);

文件上传到网络服务器(文件夹/uploads)但它有缺陷并且无法使用,当我使用filezilla调用下载时错误:严重文件传输错误

Windows 服务器 6.2、IIS 8.0

【问题讨论】:

    标签: php laravel file-upload laravel-4 iis-8


    【解决方案1】:

    这很好用。

        if(Input::Hasfile('image')){
            $files = Input::file('image');
            $filename = md5(uniqid()).'.'.$files->getClientOriginalExtension();
            $ext = explode('.',$filename);
            $ext = strtolower($ext[count($ext)-1]);
            $upload_success = $files->move($destinationPath, $filename);
        }else{
            $filename = Input::get('upload_image','');
        }
    

    【讨论】:

      猜你喜欢
      • 2014-04-17
      • 1970-01-01
      • 2018-05-09
      • 2015-02-25
      • 1970-01-01
      • 1970-01-01
      • 2012-05-10
      • 1970-01-01
      • 2016-09-29
      相关资源
      最近更新 更多