Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.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
Laravel 我不断地得到;函数名必须是字符串";错误_Laravel_Laravel 5 - Fatal编程技术网

Laravel 我不断地得到;函数名必须是字符串";错误

Laravel 我不断地得到;函数名必须是字符串";错误,laravel,laravel-5,Laravel,Laravel 5,我正在使用laravel构建一个站点,在尝试上载图像时出现了此错误。我是初学者,能给我一些帮助吗 $user = Auth::user(); $user->name = $request('name'); $user->update(); $file = $request->file('image'); $filename = $request->name . '-' . $user->id . '.jpg'; $user->nam

我正在使用laravel构建一个站点,在尝试上载图像时出现了此错误。我是初学者,能给我一些帮助吗

$user = Auth::user();
    $user->name = $request('name');
    $user->update();
    $file = $request->file('image');
    $filename = $request->name . '-' . $user->id . '.jpg';
$user->name=$request('name'); $request是变量not func,因为$

$user->name=$request('name');
$request是变量not func,因为$

没有遵循PHP中的:$request('name')

我猜您将使用$request->get('name')

对于上传图像,您可以使用以下代码,尽管我更喜欢使用


因为您没有遵循PHP中的:$request('name')

我猜您将使用$request->get('name')

对于上传图像,您可以使用以下代码,尽管我更喜欢使用


哪个错误?请在问题中包含错误消息。Symfony\Component\Debug\Exception\FatalThrowableError与消息“函数名必须是字符串”一起引发。这是来自XAMPP的消息。哪个错误?请在问题中包含错误消息。Symfony\Component\Debug\Exception\FatalThrowableError与消息“函数名必须是字符串”一起引发。这是来自XAMPP的消息。那么,我该怎么办?您使用的是类似变量的函数。稍后,您通过键入$request->name来访问名为name的变量的属性,因此将$request(“”“name”)更改为$request->name谢谢,兄弟。明白了。那么,我该怎么办?你在使用类似变量的函数。稍后,您通过键入$request->name来访问名为name的变量的属性,因此将$request(“”“name”)更改为$request->name谢谢,兄弟。知道了。
//Auth::loginUsingId(1); #You can test your code without a real login

$data = $request->only(['name']);

    if (request()->hasFile('image')) {
        $file = request()->file('image');
        $fileName = md5($file->getClientOriginalName() . time()) . "." . $file->getClientOriginalExtension();
        $destinationPath = public_path('/images/'); //// I assume you have a folder named images in public.
        $file->move($destinationPath, $fileName);

        $data['avatar'] = $destinationPath.$fileName; // I assume you have a field named avatar in users table.
    }

    return $data; // Try this line for a better understanding then comment it


    Auth::user()->update($data);