public function deleteFile() { if (Auth::guest()) { return Redirect::to('/'); } $folder_id = AppFile::deleteFile(Request::input('delete_file_id'), $this->ViewTemplate['root_folder_id']); return Redirect::to($this->RedirectPath($folder_id)); }
public function search() { if (!Request::ajax()) { return Redirect::to('/'); } $q = Request::input('q'); $view = ['results' => AppFile::search($q), 'root_id' => Folder::getRootId()]; return view('ajax/search', $view); }
public static function upload($id, $file) { $filename_exp = explode('.', $file->getClientOriginalName()); $extention = array_pop($filename_exp); $fileSize = $file->getClientSize(); $usedSpace = AppFile::getAccountSpaceInfo(); $freeSpace = Config::get('constants.CAPACITY') - $usedSpace[0]->used_space; if ($fileSize > $freeSpace) { return false; } do { $fileName = Str::random(20) . '.' . $extention; $is_filename = DB::select('SELECT count(file_name) as is_filename FROM files WHERE file_name = "' . $fileName . '"'); } while ($is_filename[0]->is_filename > 1); $root = Folder::getRootId(); $path = public_path() . '/users_files/'; $path .= $root == $id ? $root : $root . '/' . $id; $mimetypes = new \GuzzleHttp\Mimetypes(); if ($file->move($path, $fileName)) { DB::table('files')->insert(['name' => $file->getClientOriginalName(), 'file_name' => $fileName, 'folder_id' => $id, 'user_id' => Auth::id(), 'mime' => $mimetypes->fromExtension($extention), 'size' => $fileSize]); } return true; }