[英]Call to undefined function getClientOriginalName() in Laravel 8
I want to use the function getClientOriginalName()
for making a new name for the photo I take from the user.我想使用 function getClientOriginalName()
为我从用户那里拍摄的照片命名。 But as I said before, it displays an error that says that this function is undefined.但正如我之前所说,它显示一个错误,指出这个 function 是未定义的。
$pic = $request->photo;
$newPic = time().$pic.getClientOriginalName();
The method getClientOriginal name exists on the UploadedFile instance.方法 getClientOriginal 名称存在于 UploadedFile 实例中。 To get the instance you should get by the file() method from $request object要获取实例,您应该通过 $request object 中的 file() 方法获取
$pic = $request->file('photo');
$newPic = time().$pic->getClientOriginalName();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.