what do you want to do after that you cannot do before?
Laravel do some action after user finishes downloading file
Currently I do this to send file to user:
return response()->download($path);
// or
return response()->file($path);
but how can I do some actions after user finishes downloading the file? Does backend sends the whole file at once to user, and so I can't check when user will completely download it? or the backend sends files with speed of user's internet speed?
@amir5 Laravel generates a response with the contents of the file and the correct headers to force a download, hands that off to the web server to handle the actual transfer, and then terminates, executing any closures defined with the defer() helper.
You won't really know if the user has successfully downloaded the file or not, they could abort it themselves halfway through. You'll have to assume that if they've clicked the button and the response was successfully sent, they've technically downloaded the file.
Please or to participate in this conversation.