Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在laravel框架中上载配置文件图像_Php_Html_Laravel - Fatal编程技术网

Php 在laravel框架中上载配置文件图像

Php 在laravel框架中上载配置文件图像,php,html,laravel,Php,Html,Laravel,您好,我是laravel framework的新手,我正在开发一个仪表板,当用户在仪表板中更新其详细信息以及个人资料照片时,我没有收到任何错误,但当用户仅更新细节时,保持图像与更新图像相同,我收到一个错误:在非对象上调用成员函数getClientOriginalName 我的blade.php是: {{ Form::open(array('route' => 'account.profile-update', 'class' => 'form-horizontal', 'files'

您好,我是laravel framework的新手,我正在开发一个仪表板,当用户在仪表板中更新其详细信息以及个人资料照片时,我没有收到任何错误,但当用户仅更新细节时,保持图像与更新图像相同,我收到一个错误:在非对象上调用成员函数getClientOriginalName

我的blade.php是:

{{ Form::open(array('route' => 'account.profile-update', 'class' => 'form-horizontal', 'files'=>true)) }}

<div class="uploader" id="uniform-file">
                    {{Form::file('fileinput')}}
                    <span class="filename" style="-webkit-user-select: none;">Upload Image</span>
                    <span class="action" style="-webkit-user-select: none;">Browse</span>
                </div>
                <div>Please upload image of size 150x150 pixels</div>
            </div>
my UserRepository.php:

   public function updateUser(array $attributes)
{
    $user = $this->getLoggedUser();
    if (strcmp($user->first_name, $attributes ['first_name']) !== 0)
        $user->first_name = $attributes ['first_name'];
    if (strcmp($user->last_name, $attributes ['last_name']) !== 0)
        $user->last_name = $attributes ['last_name'];
    if (strcmp($user->email, $attributes ['email']) !== 0)
        $user->email = $attributes ['email'];
    $this->updateUserInfo($attributes);
    if ($user->save()) {
        return true;
    } else {
        $this->messageBag->add('update_profile', 'Error while saving user details in profile page');
        return false;
    }
}

 private function updateUserInfo($attributes)
{
    $user_detail = UserDetail::where('user_id', '=', $this->getLoggedUserID())->firstOrFail();
    if (array_key_exists('fileinput', $attributes)) {
        if (!is_null($user_detail->picture)) {
            File::delete(public_path() . $user_detail->picture);
        }
        $user_detail->picture = $this->getImageName($attributes);
    }
    $user_detail->updateIfKeyExists($attributes);
}

   private function getImageName(array $attributes)
{
    if (!array_key_exists('fileinput', $attributes)) {
        return null;
    }
    $file = Input::file('fileinput');
    $destinationPath = public_path().Config::get('far.profile_pic_folder');                                    
    $temp_filename = 't_' . str_random(6) . '_' . substr($file->getClientOriginalName(), -40);
    $new_filename = substr($temp_filename, 2);
    $uploadSuccess = $file->move($destinationPath, $temp_filename);
    //TODO - check and handle for large filesize
    $img = Image::make($destinationPath . $temp_filename)->resize(150, 143)->save($destinationPath . $new_filename);
    File::delete($destinationPath . $temp_filename);
    return Config::get('far.profile_pic_folder') . $new_filename;
}
请帮我解决这个问题。
提前感谢

您需要安装在composer.json文件interference/image:~2.0中添加的用于上载图像的软件包

看这里

您的json文件如下所示

"require": {
        "laravel/framework": "4.2.*",
        "robclancy/presenter": "1.3.*",
        "intervention/image": "~2.0"
    },
在json文件中添加这个之后。 运行编写器更新

"require": {
        "laravel/framework": "4.2.*",
        "robclancy/presenter": "1.3.*",
        "intervention/image": "~2.0"
    },