Closed selay closed 8 years ago
How big are the files you're seeing this happen with? Are you seeing that the entire file is uploaded completely?
I did some testing, and with files around 1MB, abort worked very consistently. With smaller files, around 200KB, it was less consistent, though I suspect that had more to do with the files already being transferred before abort could stop it.
Hmm, Actually I tested with small files - I think less than 1mb (I see your point now, I hadn't thought it would be related to file size). But I aborted before halfway - if progress was correct. I thought it would stop upload and remove the incompletely uploaded file. Or if it goes on, it would behave as a success process response. But I think when I tested, once the file is aborted but still uploaded, the JavaScript didnt return success although I could see the file in the upload folder. I guess it no longer listens for response after abort is pressed, right?
Do you think it is better to still listen for the success response when the file is transferred despite abort? Or maybe to respond that it can't be aborted in this case.
I know it is a bit tricky.
@selay There won't be a success response if the upload is aborted, even if the file is transferred. When the abort
method is called on the XMLHttpRequest
object, the request is killed.
The only way I can think of to do that would be to add some kind of checking procedure inside the onAbort()
callback where you send an ajax request to the server to check if the upload was actually completed.
It has a bit security side and also it is complicated if you change file name in the backend, multiple files involved etc. Maybe, just it is easier to remove abort button for <1mb files from the beginning and remove for bigger files after 25% progress.
When abort button is clicked, it behaves as expected for the front-end and console shows that upload was aborted.
However, behind the scenes, the upload continues and I can see the file eventually appearing in the upload destination folder.
Using chrome Version 45.0.2454.93 m/Windows 8