Esempio n. 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['nama_download' => 'required|max:200', 'image' => 'required']);
     $data['nama_download'] = $request->nama_download;
     if ($request->hasFile('image')) {
         $data['file_download'] = $this->savePhoto($request->file('image'));
     }
     if (Download::create($data)) {
         \Flash::success('Download Berhasil Disimpan');
     } else {
         \Flash::info('Download Gagal Disimpan');
     }
     return redirect('admin/download');
 }
 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;
 }
Esempio n. 3
0
 public function fundFileUploadInsert(Request $request)
 {
     $id = $request->input('id', 0);
     $completed = [];
     if ($request->hasFile('files')) {
         $files = $request->file('files', null);
         foreach ($files as $key => $file) {
             $fileSize = $file->getSize();
             $fileName = $file->getClientOriginalName();
             // $filePath=
             $filePath = 'file/' . $fileName;
             $file->move('file/', $fileName);
             $download = Download::create(['file_path' => $filePath, 'fund_id' => $id]);
             if ($download) {
                 array_push($completed, (object) array('name' => $fileName, 'deleteType' => 'DELETE', 'size' => $fileSize, 'url' => url('/') . '/' . $filePath, 'deleteUrl' => route('fund_file_delete', array('download_id' => $download))));
             }
         }
     }
     return response()->json(['files' => $completed]);
 }