Fixed to prevent overwritting an existing file.

svn
Loic d'Anterroches 2008-08-05 20:09:20 +02:00
parent 330fa62554
commit 884a41fbba
1 changed files with 3 additions and 0 deletions

View File

@ -70,6 +70,9 @@ class IDF_Form_Upload extends Pluf_Form
if (!preg_match('/\.(png|jpg|jpeg|gif|bmp|psd|tif|aiff|asf|avi|bz2|css|doc|eps|gz|mdtext|mid|mov|mp3|mpg|ogg|pdf|ppt|ps|qt|ra|ram|rm|rtf|sdd|sdw|sit|sxi|sxw|swf|tgz|txt|wav|xls|xml|wmv|zip)$/i', $this->cleaned_data['file'])) {
throw new Pluf_Form_Invalid(__('For security reason, you cannot upload a file with this extension.'));
}
if (file_exists(Pluf::f('upload_path').'/'.$this->project->shortname.'/files/'.$this->cleaned_data['file'])) {
throw new Pluf_Form_Invalid(sprintf(__('A file with the name "%s" is already available for download.'), $this->cleaned_data['file']));
}
return $this->cleaned_data['file'];
}