Gargron / fileupload

PHP FileUpload library that supports chunked uploads
MIT License
459 stars 87 forks source link

How to detect validation errors? #44

Closed kwebble closed 7 years ago

kwebble commented 7 years ago

I'm evaluating this component and would like to know how code should determine if an upload was skipped and get the error that the validator detected?

In the returned files array error and errorCode are always 0, even when a validator determined that an upload is invalid.

I saw FileUpload::process() returns a new File instance. This object does not include the error detected during processing.

adelowo commented 7 years ago

Sorry for the late response.

I don't get this, i get the error messages if an upload fails. Below is a snapshot.

screenshot from 2017-02-20 09 04 44

As an aside, what validator are you making use of ?

adelowo commented 7 years ago

I'd like to clear this issue out as quick as possible as it seems to be the only reason i haven't pushed a new tag from the hot-fix branch

kwebble commented 7 years ago

You don't have to wait on me for tagging, perhaps I'm misunderstanding something.

And I already added some validation outside this component to handle the situation in my project.

kwebble commented 7 years ago

I investigated some more and now think the problem is caused by #37. In that situation the result is an initial $fileInfo based on an empty $file_path.

adelowo commented 7 years ago

@kwebble , you make use of a custom validator ? I wanted to ask if you were setting the error message after a failed validation (https://github.com/Gargron/fileupload/blob/master/src/FileUpload/Validator/MimeTypeValidator.php#L54-L56) but since you mentioned #37 is the case - the reporter also says the fix works- . Lemme push those changes.

adelowo commented 7 years ago

I have done that already, you can test to make sure it works.. Tag version is 1.4.1

kwebble commented 7 years ago

Tested and got an error message if validation fails, nice!

adelowo commented 7 years ago

Awesome then

adelowo commented 7 years ago

Since this is marked as fixed, i am closing this