When I upload a file with Krajees Bootstrap Fileinput, I perform a server side validation of the file. When something goes wrong, I output a JSON-Object simply with {error:'Something went wrong'}
. The Plugin displays the error perfectly.
But then: When I press again "upload" just after that, the $_FILES
array in the called submit PHP script is empty. This means, the plugin does not send the file again even if it has notified that an error has occurred.
Why would the plugin only upload the file once even if it detects that there was an error? Are there any methods that can "reset" the "uploaded state" of the file? (I'm only uploading one file).
I already checked the file events but none of them brought me to the desired result, instead they kind of destroyed the whole upload form with certain buttons being suddenly disabled and so on.
I finally found out the exact point, where the problem could be solved:
On line 1705 in the function updateUploadLog, the function self.updateStack
is called. This call simply clears the file stack and causes a later process to empty the form input. Simply commenting out this line does the trick, but only if you reload after success, because somehow fnSuccess
is also called when an error is found.
@Angad thank you very much for your solution triggering input, thanks to that I found a place to start the search again ;)