-1

I want to use the function getClientOriginalName() for making a new name for the photo I take from the user. But as I said before, it displays an error that says that this function is undefined.

$pic = $request->photo;
$newPic = time().$pic.getClientOriginalName();
Karl Hill
  • 12,937
  • 5
  • 58
  • 95

1 Answers1

3

The method getClientOriginal name exists on the UploadedFile instance. To get the instance you should get by the file() method from $request object

$pic = $request->file('photo');
$newPic = time().$pic->getClientOriginalName();
Donkarnash
  • 12,433
  • 5
  • 26
  • 37