0

I am trying to upload an image to public folder but I am unable to do this. Following is the code of storing the image.

if($request->hasFile('picture'))
{
    $file = $request->file('picture');
    $size = $file->getSize();
    $fileNameWithExt = $file->getClientOriginalName();
    $fileName = pathinfo($fileNameWithExt, PATHINFO_FILENAME);
    $extension = $request->file('picture')->getClientOriginalExtension();
    $fileNameToStore = $fileName.'_'.time().'.'.$extension;
    $destinationPath = 'img/';
    $file->move($destinationPath, $fileNameToStore);
}
  • Welcome to Stack Overflow! Please specify the current behavior of your code: What is the input/output, do you get errors/exceptions, etc. This makes it much easier for us to help you. – janw Mar 16 '20 at 10:48
  • I am getting the following error when the save method is called: SplFileInfo::getSize(): stat failed for C:\xampp\tmp\phpD89C.tmp – Uzair Ahmad Mar 16 '20 at 10:56

0 Answers0