コード例 #1
0
 /**
  * Delete downloadable file from path and DB
  *
  * @param $id
  * @return mixed
  */
 public function deleteFile($id)
 {
     $file = Download::find($id);
     File::delete($file->filename);
     $file->delete();
     return redirect()->back()->with('flash_message', $file->filename . ' deleted');
 }
コード例 #2
0
 public function uploadFile($file, $id)
 {
     $download = Download::find($id);
     if (!$download) {
         $download = Download::create(['slug' => str_random(10), 'is_temporary' => true]);
     }
     $id = $download->id;
     $filename = $file->getClientOriginalName();
     $extension = MediaHelp::getExtension($filename);
     $download->file = $filename;
     $download->save();
     $download_path = 'web/download';
     if (!Storage::disk('public')->exists($download_path)) {
         Storage::disk('public')->makeDirectory($download_path);
     }
     $path = $download_path . '/' . $id;
     if (Storage::disk('public')->exists($path)) {
         Storage::disk('public')->deleteDirectory($path);
     }
     Storage::disk('public')->makeDirectory($path);
     $file->move($path, $filename);
     return $download;
 }
コード例 #3
0
 public function fundFileDelete(Request $request, $downloadid)
 {
     $id = $request->input('id', 0);
     $result = null;
     $download = Download::find($downloadid);
     if ($download) {
         // Remove old file from directory
         if (file_exists($download->file_path)) {
             $result = unlink($download->file_path);
             $download->delete();
         }
     }
     if ($result) {
         return response()->json(['id' => $downloadid]);
     }
     return response()->json(['error' => 'Error, can not remove file.']);
 }
コード例 #4
0
ファイル: DownloadController.php プロジェクト: cakraamin/toko
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Download::find($id)->delete();
     \Flash::success('File Download Berhasil Dihapus');
     return redirect('admin/download');
 }