Search
 
SCRIPT & CODE EXAMPLE
 

PHP

upload pdf file in laravel

//first run this command to generate symbolic link
php artisan storage:link

//then in controller function
$fileTemp = $request->file('file');
if($fileTemp->isValid()){
  $fileExtension = $fileTemp->getClientOriginalExtension();
  $fileName = Str::random(4). '.'. $fileExtension;
  $path = $fileTemp->storeAs(
  	'public/documents', $fileName
  );
}
//above code will save your file in 'storage/app/public/documents' location
//and using symbolic link we can access this file here 'public/storage/documents'

//Now Open or download file in blade template
<a href="{{url(Storage::url($document['file']))}}">Open/Download</a>
Comment

upload a pdf file laravel

class FileController extends Controller
{
    // ...

    public function upload(Request $request)
    {
        $uniqueFileName = uniqid() . $request->get('upload_file')->getClientOriginalName() . '.' . $request->get('upload_file')->getClientOriginalExtension());

        $request->get('upload_file')->move(public_path('files') . $uniqueFileName);

        return redirect()->back()->with('success', 'File uploaded successfully.');
    }

    // ...
}
Comment

PREVIOUS NEXT
Code Example
Php :: how to get last executed query in laravel 
Php :: php remove last 3 letters from string 
Php :: table has column laravel 
Php :: validation not exists with this id laravel 
Php :: json whereIn laravel 
Php :: count with left join in laravel 
Php :: how to use php echo data in javascript 
Php :: random array php 
Php :: htaccess php version 
Php :: if is alphabet php 
Php :: laravel old value not working in textarea 
Php :: laravel eloquent to array key value 
Php :: php qrscanner webcam 
Php :: compile custom/plain css with mix in laravel 
Php :: sum of columns laravel eloquent 
Php :: php convert month number to name 
Php :: set session after login with laravel 
Php :: current url wordpress 
Php :: laravel model created_at format edit 
Php :: laravel where multiple conditions 
Php :: php empty object 
Php :: print array items in php 
Php :: select values from mysql using php array of ids 
Php :: join in laravel eloquent 
Php :: get value by today yesterday in laravel 
Php :: check variable type in php 
Php :: get data in descending order in laravel 
Php :: how to call a helper function in blade 
Php :: delete in crud php 
Php :: PHP mysqli_close function 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =