Support the ongoing development of Laravel.io →
posted 9 years ago
Input
Last updated 2 years ago.
0

First, you get the uploaded file object.. like so:

$file = Input::file('file');
$tempPath =$file->getRealPath();

Note that you don't really need to 'move' the file to another folder since it is going into db. Next, you capture the 'contents' of the (temp) file and move into the desired database column:

DB::table('tablename')->insert(array(
'doc_attachment'=> File::get($tempPath) );

(of course, ample error checking is warranted for file operations.. but this is the basic idea)

Thanks!

Last updated 2 years ago.
0

Why would you save the contents in the database? Just save the filename and use the filesystem to store files..

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

jaspertan jaspertan Joined 22 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.