public function attachFile($id, $table, \Symfony\Component\HttpFoundation\File\UploadedFile $file)
    {
        $newFileName = md5(microtime() . '.' . strtolower($file->getClientOriginalExtension()));
        $relativePath = $table . '/' . date('Y/m/d');
        $relativeFilePath = $relativePath . '/' . $newFileName;
        $dstPath = APP_UPLOADS_DIR . '/' . $relativePath;
        $file->move($dstPath, $newFileName);
        $pic = new \Towel\Model\Pic();

        $pic->object_id = $id;
        $pic->object_type = $table;
        $pic->pic = $relativeFilePath;
        $pic->created = time();
        $pic->save();
    }
public function attachFile($id, $table, \Symfony\Component\HttpFoundation\File\UploadedFile $file)
    {
        $newFileName = md5(microtime() . '.' . strtolower($file->getClientOriginalExtension()));
        $relativePath = $table . '/' . date('Y/m/d');
        $relativeFilePath = $relativePath . '/' . $newFileName;
        $dstPath = APP_UPLOADS_DIR . '/' . $relativePath;
        $file->move($dstPath, $newFileName);
        $pic = new \Towel\Model\Pic();

        $pic->object_id = $id;
        $pic->object_type = $table;
        $pic->pic = $relativeFilePath;
        $pic->created = time();
        $pic->save();
    }
public function attachFile ( $ id , $ table , \ Symfony \ Component \ HttpFoundation \ File \ UploadedFile $ file ) { $ newFileName = md5 ( microtime ( ) . '.' . strtolower ( $ file -> getClientOriginalExtension ( ) ) ) ; $ relativePath = $ table . '/' . date ( 'Y/m/d' ) ; $ relativeFilePath = $ relativePath . '/' . $ newFileName ; $ dstPath = APP_UPLOADS_DIR . '/' . $ relativePath ; $ file -> move ( $ dstPath , $ newFileName ) ; $ pic = new \ Towel \ Model \ Pic ( ) ; $ pic -> object_id = $ id ; $ pic -> object_type = $ table ; $ pic -> pic = $ relativeFilePath ; $ pic -> created = time ( ) ; $ pic -> save ( ) ; }
It will attach the file.

@param $id
@param $table
@param \Symfony\Component\HttpFoundation\File\UploadedFile $file
It will attach the file .