Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel download file

/** @param IlluminateHttpRequest  $request
 * @return IlluminateAuthAccessResponse */
public function download(Request $request)
{
    $file = public_path(). "/images/test.jpg";
    $headers = ['Content-Type: image/jpeg'];
    if (file_exists($file)) {
        return Response::download($file, 'plugin.jpg', $headers);
    } else {
        echo('File not found.');
    }
}
Comment

How to download file with laravel

<?php
 
namespace AppHttpControllers;
 
use AppHttpControllersController;
use IlluminateHttpRequest;
 
class UserAvatarController extends Controller
{
    /**
     * Update the avatar for the user.
     *
     * @param  IlluminateHttpRequest  $request
     * @return IlluminateHttpResponse
     */
    public function update(Request $request)
    {
        $path = $request->file('avatar')->store('avatars');
 
        return $path;
    }
}
Comment

How to download file with laravel

<?php
 
namespace AppHttpControllers;
 
use AppHttpControllersController;
use IlluminateHttpRequest;
 
class UserAvatarController extends Controller
{
    /**
     * Update the avatar for the user.
     *
     * @param  IlluminateHttpRequest  $request
     * @return IlluminateHttpResponse
     */
    public function update(Request $request)
    {
        $path = $request->file('avatar')->store('avatars');
 
        return $path;
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: get wordpress id 
Php :: php artisan optimize command 
Php :: db connection postgres laravel 
Php :: php how to convert string to int 
Php :: laravel create model with migration and controller 
Php :: php 7 count result in database 
Php :: how to send html tags in twig template 
Php :: Classified script with mobile app laravel 
Php :: php filter name 
Php :: php file get content replacing & with &amp; 
Php :: NUMBER ONLY IN PHP 
Php :: loop through values of hash php 
Php :: teruglopende for loop php 
Php :: iterator impliment php 
Php :: laravel with trashed 
Php :: wordpress get post taxonomy terms 
Php :: I need help 
Php :: laravel sentence word count 
Php :: route group controller laravel 
Php :: how check if method is not in class in php 
Php :: deleteAll cakephp 2 
Php :: array flip php 
Php :: get table name of model laravel inside the model 
Php :: xdebug vscode docker 
Php :: curl php post 
Php :: translate youtube link into iframe in laravel 
Php :: Carbon Format date with timezone in views Laravel 
Php :: jquery ajax 500 internal server error php 
Php :: laravel mongodb field delete (key delete) (column delete) drop 
Php :: php support block-level scope 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =