Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Image Upload in Laravel

// Image uploaad laravel
if (!empty($request->files) && $request->hasFile('image')) {
    $input1 = array();
    $upload_path = 'storage/uploads/customers/';
    $old_file = $upload_path . '/' . $input['old_image'];
    if (Storage::exists($old_file)) {
        //delete previous file
        unlink($old_file);
    }
    $file = $request->file('image');
    $file_name = $file->getClientOriginalName();
    $type = $file->getClientOriginalExtension();
    $real_path = $file->getRealPath();
    $size = $file->getSize();
    $size_mbs = ($size / 1024) / 1024;
    $mime_type = $file->getMimeType();

    $file_temp_name = 'profile_' . time() . '.' . $type;
    $old_file = $upload_path . '/' . $file_temp_name;

    $path =  storage_path() . '/app/public/uploads/customers/' . $file_temp_name;
    $img = Image::make($file)->resize(300, 300);
    $img->save($path);
    $input1['image'] = $file_temp_name;
}
Source by www.itsolutionstuff.com #
 
PREVIOUS NEXT
Tagged: #Image #Upload #Laravel
ADD COMMENT
Topic
Name
7+4 =