File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,8 @@ lifecycle callbacks implemented::
196
196
public function preUpload()
197
197
{
198
198
if ($this->file) {
199
- $this->setPath($this->generatePath($this->file));
199
+ // do whatever you want to generate a unique name
200
+ $this->setPath(uniq().'.'.$this->file->guessExtension());
200
201
}
201
202
}
202
203
@@ -212,7 +213,7 @@ lifecycle callbacks implemented::
212
213
// you must throw an exception here if the file cannot be moved
213
214
// so that the entity is not persisted to the database
214
215
// which the UploadedFile move() method does
215
- $this->file->move($this->getUploadRootDir(), $this->generatePath($this->file) );
216
+ $this->file->move($this->getUploadRootDir(), $this->path );
216
217
217
218
unset($this->file);
218
219
}
@@ -226,12 +227,6 @@ lifecycle callbacks implemented::
226
227
unlink($file);
227
228
}
228
229
}
229
-
230
- protected function generatePath(UploadedFile $file)
231
- {
232
- // do whatever you want to generate a unique name
233
- return uniq().'.'.$this->file->guessExtension();
234
- }
235
230
}
236
231
237
232
If you want to use the ``id `` as the name of the file, the implementation is
You can’t perform that action at this time.
0 commit comments