0

我正在尝试将图像上传到公用文件夹,但我无法执行此操作。以下是存储图像的代码。

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);
}
4

0 回答 0