Is it possible to test file download in Laravel 5.4? - laravel

With Laravel 5.4, it's now easy to test file upload: https://laravel.com/docs/5.4/http-tests#testing-file-uploads
Is there a way to test file download too? Ex: I want to check if a CSV is generated on a click on a button.
I did not found anything about this. What are the best practices about file download testing in Laravel?

you can try with this solution to check if the file was generated while the clicked button
if($request->hasfile('nameOfInput'))
{
//your code
}

Related

Uploading file to sharepoint and returning the url of the uploaded file

I am using laravel trying to upload the file to sharepoint folder and want to return the url of the uploaded file. I have went through the documentation and various article but not feeling comfortable and didnt found any clear ways to acheive it.
Request you to please guide with way to start with.

How is it possible to include a .blade file from outside of the Laravel project?

I have a Laravel 5.8 project and I'm using Blade to display the website.
However, I have .blade files outside of the Laravel project, that I'd like to #include() or display from the controller with return view(); with blade.
Here is a similar folder structure:
/var/www/examplesite1/
/var/www/examplesite2/
/var/www/laravel/
/var/www/storage/blade/
So for example the Laravel application is on the /var/www/laravel/ path. The blade file I'd like to get is from this path /var/www/storage/blade/.
What I tried was:
return view('/var/www/storage/blade/file.blade.php');
include('/var/www/storage/blade/file.blade.php');
None of them worked, becauase I got an error like this: View [.var.www.storage.blade.file.blade.php] not found.
I also tried it with omitting the 'blade.php' from the end, but it's the same.
Is it possible to include a blade file from outside the Laravel project? If yes, how?
You can add new directories to the views paths in config/views.php. https://laravel-news.com/laravel-view-path

How can i download file in Codeingiter

I want to give download file option my webpage , but the file which i want to download is present on download link of another website , how can i directly download it from my webpage ,using CODEIGNITER
If you want download a file direct to your web site root folder use this code.
file_put_contents($_SERVER["DOCUMENT_ROOT"]."/your_folder_name/add_file_name.jpg..ect", "your_file_path_want_to_download");
hope it will help you.
You can download files using download helper in codeigniter. first you need to and $this->load->helper('download'); in your constructor or method. after that use following code for download.
force_download('/path/to/photo.jpg', NULL);
You can Use download helper in Codeigniter. simple load helper in your controller where you need like this
$this->load->helper('download');
here is ex
$data = 'Here is some text!';
$name = 'mytext.txt';
force_download($name, $data);

What's the right way to save HTML in Laravel using eloquent particularily?

Do I need to use HTML::entities(Input::get('description')); in laravel to save the htmlText gotten off CKEditor. or has anyone tried it out... thanks.
The idea is to preserve the formatting and retain the text to display on another page, alternatively is there any package in packagist that one can download to strip and work on html inputs...
Please Note :: i am currently using laravel 4.2, so if there are changes in higher versions how can i implement it here..
Add Controller File:
echo e(Input::get('description'));

Where to place sitemap.xml in playframework 2.1 project

Just for a quick question. Where does the sitemap.xml to place in play framework 2.1 project? do we need to configure the route file to the sitemap.xml?
Appreciate your help
thanks,
Best rgsd,
a1ucard
Either an Action generates dynamically your sitemap.xml, then you have to configure the URL like this:
GET /sitemap.xml controllers.Application.sitemapGenerator
Either you generate your sitemap.xml by hand, then put it in the public folder of your Play app, and then add an Asset route:
GET /sitemap.xml controllers.Assets.at(path="/public", file = "sitemap.xml")

Resources