Aug 21, 2017
0
Level 2
How to use pg_unescape_bytea
I successfully stored file in database (bytea datatype), but when i try to retrive my file it throws error
Method Illuminate\Support\Collection::__toString() must return a string value
My controller
public function index()
{
$img = DB::table('images')->pluck('file');
$decode = pg_unescape_bytea($img);
dd($decode);
return view('home',compact('decode'));
}
// To store file in database
public function save(Request $req)
{
$resume = Input::file('file');
$extenstion = file_get_contents($resume);
$file = pg_escape_bytea($extenstion);
$data = array('file' => $file);
DB::table('images')->insert($data);
return redirect()->back();
}
Please or to participate in this conversation.