josegonzalez/upload — pull request #93 by intuxicated (2013-01-22 23:13:17+00:00)
Title: add custom filename option

hi and thanks for great plugin.
i explained about how to use custom filename option in readme file. my English is not good so maybe i missed something in readme.

i added 2 function to UploadBehavior and modified afterSave to add this feature.
there is several ways to implement custom filename, i decide to use Pattern. its very simple and easy to use.

for example this pattern :

```
{#NAME}_{id}
```

will return something like this : `orginal_name_1`.
you can create function in your model and call it to generate custom filename:

```
{!myMethod}-suffix
```

```php
class Model extends AppModel {
public function myMethod($filename = ''){
return md5($filename);
}
}

in above example suffix is just a simple text. and $filename is optional.it will be passed to each method you call in `Pattern`.

i used http://stackoverflow.com/a/13767184/440754 sanitizeFilename function to remove unsupported character from filename.