When I try and upload a file as follows:
$name = $img->getClientOriginalName();
$fullPath = Product::getUploadPath(); // Returns public_path(); with custom directory appended
$uploaded = $img->move($fullPath, $name);
I get the below error:
Could not move the file
"/private/var/folders/1l/fxl7spqj2p113fpffm3k0sy00000gn/T/phpIgpWGy" to
"/dir/subdir/subsubdir/subsubdir/public/backend/images/products/pic.jpg" ()
For interestsake, I built the entire resolve path for the image, and passed that as an argument to the move() method. Memory served that it has worked previously.
$uploaded = $img->move($fullPath.'/'.$name);
No exceptions are thrown, however, the uploaded file, now becomes a directory:
"/dir/subdir/subsubdir/subsubdir/public/backend/images/products/pic.jpg/"
I'm very close to driving my fist through my screen.
move()method of theUploadedFileclass calls PHP'smove_uploaded_file()function. They suppress errors from that call but throw aFileExceptionwith that custom message you're seeing. The file being created as a directory with the second attempt makes sense as the first parameter is the target directory, and the second name is the file name - without a filename, only a directory is resolved.move()is called, that the given directory could have insufficient permissions? Also, when it does create directory, the directory isn't empty, seems to be the temporary PHP residing within.writepermissions and notexecutepermissions to rename the file. However, again, I refer to 'dynamically' created directory having insufficient permissions.