File download test in Symfony - file

I need to test if file will start download when user click on button.
Right now I'm clicking on download button "a.btn-info" via client and it just print text from file into PHPUnit console
$client->request('GET', $crawler->filter('a.btn-info')->attr('href'));
Thank you :)

You can simply perform request with HEAD method like
$client->request('HEAD', $crawler->filter('a.btn-info')->attr('href'));
and check if response code is 200 and there is a "Content-Disposition: attachment" header.
It will mean that file exists and will be downloaded and not opened in browser.

Related

How to download excel file that is downloadable from server in react

I am facing an issue that the file when you hit the URL in browser it auto download but in postman return characters
response from postman
how is it possible to make it downloadable from react? when hit the URL it just return the weird characters response.
I want when click a button just to look like this

How do you link to a file such that it will download rather than render in browser?

I want people to be able to click my link and download my file. But when I link to the file download on my site, it just brings them to the code for the file. I am trying to upload a .cpp file (c plus plus). It's in my downloads folder but when I link to there it displays the .cpp file rather than download it.
Any help is appreciated.
You can set the Content-Disposition header to "attachment" in your HTTP response. If you let me know what server platform, I'll try to give more detail.
You will have to write some code to set the HTTP response header ContentType to "application/x-force-download". This tells the browser what you really want is a file download, instead of the default action (file open). You will also need to set the ContentLength header. This allows the browser to display a progress bar.
If you use ASP.NET, there are some commercial product for this purpose:
http://www.essentialobjects.com/Products/EOWeb/Downloader.aspx
It basically does what stated above with a few extra features.
That's because the browser knows how to read the file - you could ask users on the page to right click on the link and click "Save Target As" rather than just having a link.

Firefox: How to execute a .bat file from a link?

Here I have a little intranet page which has some "file://" links on it. These links point to some Windows batch files. However, if I click on these links, I see only the content of this batch file. I would rather get the Firefox dialog where I can choose between open, save and cancel.
Is there a way to do that?
try with:
Content-type: application/octet-stream
Content-Disposition: attachment; filename="myfile.txt"
http://www.w3.org/TR/html4/struct/links.html
it should ask you if you want to run the bat.
If the page page is only for internal usage it will be better to try with HTA application - it will have no restricitions of the browser and you will be able to call the bat with a vbscript.

Web, Silverlight. Always show save file dialog when user try to download file

I have link to file (Inside sharepoint list) I need always to show Save file dialog.
But some browsers starts to download file without promt.
What should be done to avoid automatic download?

IE6 closes new browser window when I set iframe's source to a file download service

In our application, we have a download flow that works as follows:
On main application page has a link showing file name to download. Target of this link is _blank.
User clicks this link. We open a new window.
The new window shows a wait message, makes an ajax call first to verify the file details from server (we have server implementations for this).
There is a hidden iframe in new window. After verification of file details, I set the file download url as the source of iframe so download request is sent via iframe.
When file response is received, IE6 suddenly shows a yellow bar at the top and then closes this new window forcefully. I do not see any file save dialog.
This works fine in IE7 and IE8, although I see the yellow security bar here too but window does not close, so I can start a manual download.
Can anyone help me on this? Is this a bug in IE6 that was resolved in IE 7/8?
Best regards,
Nadeem
I got it. Actually this is a bug of IE6 and you could get more info about it here: http://support.microsoft.com/kb/896017.
Regards,
Nadeem Ullah

Resources