$attachment->filename]); return view('attachments.edit', compact('attachment', 'subTitleIcon', 'subTitle')); } /** * @param Attachment $attachment */ public function download(Attachment $attachment, AttachmentHelperInterface $helper) { $file = $helper->getAttachmentLocation($attachment); if (file_exists($file)) { $quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\')); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . $quoted); header('Content-Transfer-Encoding: binary'); header('Connection: Keep-Alive'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . $attachment->size); echo Crypt::decrypt(file_get_contents($file)); } else { abort(404); } } /** * @param AttachmentFormRequest $request * @param AttachmentRepositoryInterface $repository * @param Attachment $attachment * * @return \Illuminate\Http\RedirectResponse */ public function update(AttachmentFormRequest $request, AttachmentRepositoryInterface $repository, Attachment $attachment) { $attachmentData = [ 'title' => $request->input('title'), 'description' => $request->input('description'), 'notes' => $request->input('notes'), ]; $repository->update($attachment, $attachmentData); Session::flash('success', 'Attachment "' . $attachment->filename . '" updated.'); Preferences::mark(); if (intval(Input::get('return_to_edit')) === 1) { // set value so edit routine will not overwrite URL: Session::put('accounts.edit.fromUpdate', true); return redirect(route('attachment.edit', [$attachment->id]))->withInput(['return_to_edit' => 1]); } // redirect to previous URL. return redirect(Session::get('accounts.edit.url')); } }