getPhoto laravel

public function getPhoto(Request $request)
{    $photo = new \App\Photo();
    if ($file = $request->image) {        list($type, $imageData) = explode(';', $request->image);
        list(, $extension) = explode('/', $type);
        list(, $imageData) = explode(',', $imageData);
        $fileName = uniqid() . '.' . $extension;
        $source = fopen($request->image, 'r');
        $destination = fopen('images/' . $fileName, 'w');
        stream_copy_to_stream($source, $destination);
        fclose($source);
        fclose($destination);
        $photo = \App\Photo::create(['name' => $fileName]);
        return $photo;
    }    return $photo;
}



No comments:

The Weekender: Moon metaphors, procrastinating monks, and a visit to a cheese factory

What we’re reading, watching, and listening to this week ͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ­͏     ...

Contact Form

Name

Email *

Message *