I'm using Laravel's file storage functionality to save a file:
public function dataPost(Request $request) {
$fileInForm = 'doc';
if ($request->hasFile($fileInForm)) {
$file = $request->file($fileInForm);
if ($file->isValid()) {
// Filename is hashed filename + part of timestamp
$hashedName = hash_file('md5', $file->path());
$timestamp = microtime() * 1000000;
$newFilename = $hashedName . $timestamp . '.' . $file->getClientOriginalExtension();
Storage::disk('local')->put($newFilename, $file);
}
}
}
This does save the file, but inside a directory named the same as the file, for example:
storage/app/http://ift.tt/2dKUG0Q
or
storage/app/http://ift.tt/2d7qEXh
Is this expected? Is there any way to just store the file without a separate directory for each file?
Thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire