Determining successful download using php readfile

后端 未结 3 1542
甜味超标
甜味超标 2020-12-10 09:30

I need to know if a user selected download then clicked the cancel button, which is not the same as readfile having an error. I have inspected the count returned by the rea

3条回答
  •  佛祖请我去吃肉
    2020-12-10 10:13

    I fear the correct answer is "Impossible" - let me explain: You might be able to correctly figure out, when the file has crossed the wire, but you can't figure out reliably, whether the client threw it away or not.

    Example (chronological sequence):

    • A user on MSIE clicks download and is presented with the "Save where" Dialog.
    • While this dialog is open, the download is started in the background.
    • The user navigates around in the dialog or simply does nothing (phone rang, he talks)
    • The background download is finished, your script sees the download as complete
    • The user clicks on "cancel"
    • MSIE deletes the tempfile, the download is never stored in a user-accessible form

    Result:

    • The user sees the file as "not downloaded" - and he is correct
    • Your app sees the file as "correctly downloaded" - and it is correct

提交回复
热议问题