I have a file stored in public/files/sample.pdf. When I want to download the file using Download. It says not found. What will be the correct path. Thank you.
/files/sample.pdf
You can always use
href="{{asset('files/sample.pdf')}}"
It will be easier
You should apply url function instead of paste the directory directly.
Download
If you're really looking for a download response when clicking the link, you should have the URL link to a controller method.
<a href="{{ url('route/to/method') }}">
Now in the controller method
return response()->download(public_path('files/sample.pdf'));
Laravel responses
Related
I am using the exact same Ajax call in multiple blade templates.
If Ajax fails, I show an error jpg located in public/images/danger.png.
When I had my JS in the blade file written inline in <script> tags, it was easily accessible as I had blade helpers to access public with:
{{asset('/images/danger.png')}}
Yet now, accessing /public with:
http://"+location.host +"/public/images/danger.png
is impossible.
It would be unDRY to put the exact same AJAX call in 12 blades, no need to elaborate why..
How do you guys counter this issue?
remove /public from your route,you can directly use /images/imgname.jpg
You can just use absolute routes in your javascript files. This will however not work if your Laravel application sits in a sub folder.
"/public/images/danger.png"
just the same as used in html (in blade)
like
$('.abc').attr("src", "{{asset('imgs/male_b.svg')}}");
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);
I have issue related to Laravel routing. For example if my site is xyz.com and i have link on my home page Instagram.
Then it does not take me to the Instagram link instead of opening this link it opens the wwww.servername/laravel/public/https://www.instagram.com/myprofile/ instead. How can I open a new link?
Your link is being generated using blade functionality. However based on the discussion in the comments above, the link does not sit within a blade file, and thus the blade functionality, specifically in this case url, is not being called.
Please ensure the following:
Blade functions sit within a .blade.php file
url is called within the blade markers {{ and }}
Homepage - This will take u to homepage
This post - This will take u to your link in this case this post
Best Regards
I using Laravel Assets Pipeline(https://github.com/CodeSleeve/asset-pipeline) plugin for the my project.
I was able to successfully configure with the common JS files (jquery.js, global.js) included in the page. I have some page specific JavaScript files that needs to be included.
home.js
about-us.js
I tried with following but I think it's not the correct way to achieve this.
{{ HTML::script('assets/home.js'); }}
According to the asset-pipeline documentation it should be used like that :
<?= stylesheet_link_tag() ?>
<?= javascript_include_tag() ?>
There is a manifestFile argument which can maybe load only some specific files.
Are you sure it is compatible with HTML facade ? If it is, there is maybe a route to configure :/
And as far as I understand the documentation, you shouldn't call your script like that, one of the aim of your asset pipeline is to delegate it, isn't it ?
Hi I created a codeigniter project but when I click on a link to one of my functions, example add user, I get redirected to the main page of my local host XAMPP installation instead of being taken to the correct application url. What can be the problem? Thanks
Have you set the base URL in the CI configuration? file projectname/application/config/config.php? This might be the problem... I guess your project isn't on the webroot, but your base URL is missing the /projectname/ part.
$config['base_url'] = 'http://example.com/projectname/';
How do you create the link (can you show us the code)? If you are not using the URLHelper take a look at urlHelper.
I am just guessing, but maybe you are missing the Controller name (you have to load the UrlHelper), e.g.:
Link to the controllers method
or (see Jordan Arsenault's comment below on the usage of the site_url call for better performance):
<?= anchor('/name_of_the_controller/method_to_invoke', 'Link to the controllers method'); ?>
I hope this helps.