简体   繁体   中英

Echo not being executed before return response

I have a really simple question. I have this Controller in my Laravel application, that returns a zip file download, depending on what the user selected. So far so good. I also have this echo just before the return:

echo "<script> alert('test') </script>";

return response()->download(public_path($fileName));

My question is: the "echo" is not being executed, but if i remove the return, it is executed.. isn't the "echo" supposed to execute before the return ? Why is it not being executed?

download() forces browser to well... download given file, so there is no place to display echo text. You can use for example redirect to download page to firstly display alert box.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM