milesj / uploader

[Deprecated] A CakePHP plugin for file uploading and validating.
MIT License
193 stars 73 forks source link

Saving empty upload path #152

Closed johannesnagl closed 11 years ago

johannesnagl commented 11 years ago

I'm using Uploader 4.3.5 with the following configuration

'upload_image' => array(
  'finalPath' => '/uploads/posting/',
  'nameCallback' => 'uploaderFileNameCallback',
  'dbColumn' => 'image',
  'stopSave' => false,
  'allowEmpty' => true
)

When saving a record with leaving the "upload_image" key empty, the code processes as expected, but when looking in my debug-log, I found the following error:

2013-10-17 13:54:40 Debug: No file detected in input stream

I think, that in AttachmentBehavior's beforeSave foreach loop there is a missing

if (empty($file)) {
  continue;
}

clause.

Does someone else can repro this issue?

johannesnagl commented 11 years ago

maybe a better and more robust solution would be to throw a ValidationException, that is later on catched and decided, if we can continue (depending on the allowEmpty option).

milesj commented 11 years ago

I just tested with the same settings and no error appeared in my logs. Hrrmmm.

Will add some checks to see if it fixes it.