Storage::download working wrong in laravel 5.7 - laravel

I have a file in path:
app/public/template/templateeSkillsMatrix_Config.docx
and when i use:
return response()->download(storage_path('app/public/template/eSkillsMatrix_Config.docx'));
It is working, but when i use :
return Storage::download(storage_path('app/public/template/eSkillsMatrix_Config.docx'));
It show an error:
File not found at path: E:/project/agl/nav/New folder/DKMH/storage/app/public/template/eSkillsMatrix_Config.docx
I dont know why.
I read laravel docs , but i dont understand what is parameter of it.
Please help!

Just like #apokryfos's comment ,Storage::download(..) will automatically use the base storage path so i dont need call storage_path method. I need to call it the following:
return Storage::download('public\template\eSkillsMatrix_Config.docx');
in this line, i removed storage_path method and delete app/ in path.
and it is working for me!

Related

storing a file to a symlink in laravel 9

I'm trying to get an image from the web and store it locally in my 'app/library' folder using Laravel 9. After battling for an hour with get_file_contents, I finally discovered guzzler and the file is fetched properly. Now I'm trying to save it using the following command.
$stored = Storage::put(storage_path('app/library').'/'.$filename, $content)'
$stored shows as '1', which leads me to think that it's worked, but the file is not in my app/library folder. Nor can I find any file with the correct name anywhere in my project.
Is there something wrong with my command?
Run the storage:link command.
See https://laravel.com/docs/9.x/filesystem#the-public-disk
Thanks to lagbox for the answer. I was overthinking it and didn't need 'storage_path()'. The following worked.
$stored = Storage::put('library/'.$filename, $content)'

Illuminate\Routing\UrlGenerator::__construct(): Argument #2 ($request) must be of type Illuminate\Http\Request, null given

No command is working, I also tried to update Composer, but the case is the same. I found a guide that said to ignore the url() and asset() method, but it did not solve the issue.
Illuminate\Routing\UrlGenerator::__construct(): Argument #2 ($request)
must be of type Illumina te\Http\Request, null given, called in
D:\artyir\xampp8\htdocs\boilerplate\core\vendor\laravel\
framework\src\Illuminate\Routing\RoutingServiceProvider.php on line 65
I got that error message because I used url() in config folder.
Try not to use any url() or asset() in the config folder mainly in app.php.
I faced same problem when I used asset() function in some file in config folder, so try to remove any helper function from all config files, it prevents the loading of the app routes.
I solved this issue by changing this line:
asset('img/order_system/shopify.png')
to
'/img/order_system/shopify.png'
in config.

Laravel Storage File not found

I am trying to bind a downloadable csv template to a button which will sit in storage but i keep receiving an error i have tried below but having no luck can anyone see where i am going wrong?
Download Route
Created a download route which refers to the template in storage.
public function download()
{
return Storage::download('template.csv');
}
route file
Route::get('invites/download', 'InviteController#download')->name('invite.download');
Button
Download template
Template location
storage/app/public/template.csv
Error
This is the error i keep receiving.
League \ Flysystem \ FileNotFoundException
File not found at path: template.csv
Can i get some help to see where i am going wrong?
You can fix the issue by simply using file_get_contents() instead :
return file_get_contents(public_path('storage/template.csv'));
This will work if you have created the symlink as well php artisan storage:link,
If you want to use storage_path, then :
return file_get_contents(storage_path('app/public/'.'template.csv'));

Need to run wp_query on a separate php file for an ajax call

But it shows:
Fatal error: Class 'WP_Query' not found in
C:\wamp64\www\word\wp-content\themes\word\templates\calendar-function.php
on line 67 .
You need to include wp-load.php (it is present on root folder)
Like -
$abs_path= __FILE__;
$get_path=explode('wp-content',$abs_path);
$path=$get_path[0].'wp-load.php';
include($path);
Add this code to the file calendar-function.php
$abs_path= __FILE__;
$get_path=explode('wp-content',$abs_path);
$path=$get_path[0].'wp-load.php';
include($path);
You should use WP AJAX api, never call the file in the theme directly.
Please refer to the codex:
https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action)

codeigniter update root directory

When trying to reference a function in my controller, I get the following error. It's missing the "/angular/" in the path. How can I update the root path to include the angular directory?
Remove the / at the beginning of wherever you are trying to call your function, placing ./ might also work.

Resources