Check if filename exists before proceeding with upload
This commit is contained in:
parent
95092c2c1b
commit
74b696099c
1 changed files with 5 additions and 1 deletions
|
|
@ -14,8 +14,12 @@ class FileUploader
|
||||||
}
|
}
|
||||||
|
|
||||||
public function upload(UploadedFile $file)
|
public function upload(UploadedFile $file)
|
||||||
|
{
|
||||||
|
do
|
||||||
{
|
{
|
||||||
$filename = md5(uniqid()) . '.' . $file->guessExtension();
|
$filename = md5(uniqid()) . '.' . $file->guessExtension();
|
||||||
|
}
|
||||||
|
while(file_exists($this->getTargetDir() . '/' . $filename));
|
||||||
|
|
||||||
$file->move($this->getTargetDir(), $filename);
|
$file->move($this->getTargetDir(), $filename);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue