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 :: php random string for filename 
Php :: order by array like sql php 
Php :: PHP sha1_file — Calculate the sha1 hash of a file 
Php :: upload video file in mysqli using php 
Php :: php define() 
Php :: laravel tricks and tips 
Php :: dot after each character php 
Php :: PHP vprintf — Output a formatted string 
Php :: Add ACF to single.php 
Php :: wp_signon wordpress login subdomain 
Php :: Route::whereIn 
Php :: get table row data onclick 
Php :: how to validate students who made payment in php and mysql 
Php :: PHP $argv echo with number of words 
Php :: Get authors who has posts in category - WordPress 
Php :: faire un fichier zip en php 
Php :: laravel migration softdelete 
Php :: laravel gigapay get single payout 
Php :: check which php.ini file enabled from code 
Php :: How to generate a create table script for an existing table in php/Codeigniter 
Php :: HASHING in php double scripting 
Php :: Regenerate session ID and remove all session data 
Php :: User.php 
Php :: OroCRM Custom Bundle is loaded? 
Php :: error import php 
Php :: function() use() php clousure examples 
Php :: Laravel/Php Carmel Casing / Title Casing 
Php :: wpmu assign user to blog 
Php :: List all controllers in codeigniter HMVC structure 
Php :: php to html 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =