2

I have button upload for uploading PDF in my view, the file was saved in database.

Here is my view html:

<div class="form-group">
    {!! Form::label('file', 'File:') !!}
    <p>{!! $attatchment->file !!}</p>
</div>

So I want to save it on my local folder, how to make its works ?

I'm using this: path="/file_storage";

2
  • So you're saving the file to the server, saving the path to the database then you want to be able to download it? Is that what you're saying? Commented Sep 3, 2018 at 9:34
  • no, i want to save the file in database, also store it into file storage. how to make it works ? Commented Sep 3, 2018 at 10:08

2 Answers 2

1
$file = $request->file('avatar');
            $destinationPath = 'file_storage/';
            $originalFile = $file->getClientOriginalName();
            $filename=strtotime(date('Y-m-d-H:isa')).$originalFile;
            $file->move($destinationPath, $filename);

it will save the file in public/file_storage

Sign up to request clarification or add additional context in comments.

Comments

0
<?php
$file = $request->file('photo');
$time = microtime('.') * 10000; 
$filename = $time.'.'.strtolower( $file->getClientOriginalExtension() );
$destination = 'profile';
$file->move($destination, $filename);
?>

1 Comment

This answer was flagged as low-quality because of its length and content. Please explain your solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.