The move() method takes a directory and a file name as its arguments.
You might calculate the filename in one of the following ways:

1
2
3
4
5
6
7
8
9
10

// use the original file name$file->move($dir,$file->getClientOriginalName());// compute a random name and try to guess the extension (more secure)$extension=$file->guessExtension();if(!$extension){// extension cannot be guessed$extension='bin';}$file->move($dir,rand(1,99999).'.'.$extension);

Using the original name via getClientOriginalName() is not safe as it
could have been manipulated by the end-user. Moreover, it can contain
characters that are not allowed in file names. You should sanitize the name
before using it directly.

Read the cookbook for an example of
how to manage a file upload associated with a Doctrine entity.

If true, any errors for this field will be passed to the parent field
or form. For example, if set to true on a normal field, any errors for
that field will be attached to the main form, not to the specific field.