Support the ongoing development of Laravel.io →
posted 8 years ago
Requests
Last updated 9 months ago.
0
Solution

OK, let me answer my question for further reference.

It is not possible the way I thought, however digging the internet I came to a solution which includes redirects, meta content refresh, and javascript/jquery.

Since in my case the download is provided for users with a download code, the first page is a usual form for code entry. This posts the code to another page, and after validating the download a temporary and random download link is generated.

In this page I set the the following in the header (download.blade.php):

<meta http-equiv="refresh" content="2; url={{ $download->link }}">

and output something like "Your download will begin shortly". The number in the content value sets the delay in seconds.

Also in this page, I added a javascript interval function that checks the 'download' cookie repeatedly.

var checker = window.setInterval(function(){
	var cookie = $.cookie('download');
	if (cookie) {
		Update();
		clearInterval(checker);
	}
}, 500);

(This example uses jquery.cookie.js plugin! You can also achive the same with pure javascript.)

The meta refresh sends a get request to our temporary download link (stored in session) and gets the download response with the download cookie. Here, it is important that the cookie should be readable by script, because default Laravel cookies are httponly. For this you need to set it this way:

Cookie::queue('download', 'true', 1, null, null, false, false);

The content of the cookie is not important, because it is encrypted and our javascript checks only its existence anyway.

When the script finds the 'download' cookie, it updates the part "Your download will begin shortly" to something like "Thank you for downloading.".

Last updated 9 months ago.
0

Hi, I came here because you asked how to put adminer in your laravel install and I put you off.

Here is your solution: https://github.com/kohkimakimoto/LaravelAdminer

I think you will get notified about this post.

If so, reply me at marcin[at]lawniczak.me

Last updated 9 months ago.
0

Sign in to participate in this thread!

Full Stack Europe

Your banner here too?

iben12 iben12 Joined 14 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 Laravel.io - All rights reserved.