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
|
|
@ -15,7 +15,11 @@ class FileUploader
|
||||||
|
|
||||||
public function upload(UploadedFile $file)
|
public function upload(UploadedFile $file)
|
||||||
{
|
{
|
||||||
$filename = md5(uniqid()) . '.' . $file->guessExtension();
|
do
|
||||||
|
{
|
||||||
|
$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