getSize(); $clientName = $file->getClientOriginalName(); $md5 = md5($clientName . time()); $md5_filename = $md5 . '.' . $file->getClientOriginalExtension(); $fileMimeType = $file->getMimeType(); try { if(!$file->move($path, $md5_filename)){ return false; } $real_path = $path . '/' . $md5_filename; $url_path = $rel_path . '/' . $md5_filename; $attachment = new BaseAttachmentModel(); $attachment->name = $clientName; $attachment->md5 = $md5; $attachment->path = $real_path; $attachment->url = $url_path; $attachment->size = $fileSize; $attachment->file_type = $fileMimeType; if ($attachment->save()) { return env('APP_URL').'/attachment/'.$md5; } else { @unlink($real_path); return false; } } catch (FileException $e) { return false; } } }