src/Kunstmaan/FormBundle/Entity/FormSubmissionFieldTypes/FileFormSubmissionField.php
public function upload($uploadDir, $webDir)
    {
        // the file property can be empty if the field is not required
        if (null === $this->file) {
            return;
        }

        // sanitize filename for security
        $safeFileName = $this->getSafeFileName($this->file);

        $uuid = uniqid();
        $this->setUuid($uuid);

        // move takes the target directory and then the target filename to move to
        $this->file->move(sprintf('%s/%s', $uploadDir, $uuid), $safeFileName);

        // set the path property to the filename where you'ved saved the file
        $this->fileName = $safeFileName;

        // set the url to the uuid directory inside the web dir
        $this->setUrl(sprintf('%s%s/', $webDir, $uuid) . $safeFileName);

        // clean up the file property as you won't need it anymore
        $this->file = null;
    }
public function upload($uploadDir, $webDir)
    {
        // the file property can be empty if the field is not required
        if (null === $this->file) {
            return;
        }

        // sanitize filename for security
        $safeFileName = $this->getSafeFileName($this->file);

        $uuid = uniqid();
        $this->setUuid($uuid);

        // move takes the target directory and then the target filename to move to
        $this->file->move(sprintf('%s/%s', $uploadDir, $uuid), $safeFileName);

        // set the path property to the filename where you'ved saved the file
        $this->fileName = $safeFileName;

        // set the url to the uuid directory inside the web dir
        $this->setUrl(sprintf('%s%s/', $webDir, $uuid) . $safeFileName);

        // clean up the file property as you won't need it anymore
        $this->file = null;
    }
public function upload ( $ uploadDir , $ webDir ) { // the file property can be empty if the field is not required if ( null === $ this -> file ) { return ; } // sanitize filename for security $ safeFileName = $ this -> getSafeFileName ( $ this -> file ) ; $ uuid = uniqid ( ) ; $ this -> setUuid ( $ uuid ) ; // move takes the target directory and then the target filename to move to $ this -> file -> move ( sprintf ( '%s/%s' , $ uploadDir , $ uuid ) , $ safeFileName ) ; // set the path property to the filename where you'ved saved the file $ this -> fileName = $ safeFileName ; // set the url to the uuid directory inside the web dir $ this -> setUrl ( sprintf ( '%s%s/' , $ webDir , $ uuid ) . $ safeFileName ) ; // clean up the file property as you won't need it anymore $ this -> file = null ; }
Move the file to the given uploadDir and save the filename

@param string $uploadDir
Move the file to the given uploadDir and save the filename