public function upload() { return \Plupload::file('file', function ($file) { // Store the uploaded file $file->move(storage_path() . '/files', $file->getClientOriginalName()); // This will be included in JSON response result return ['success' => true, 'message' => 'Upload successful.', 'file' => $file->getClientOriginalName()]; }); }
public function upload() { if (Session::get('isLogged') == true) { return \Plupload::file('file', function ($file) { // екстракт на наставката $originName = $file->getClientOriginalName(); $array = explode('.', $originName); $extension = end($array); // името без наставка $name = self::normalizeString(pathinfo($originName, PATHINFO_FILENAME)); // base64 од името на фајлот $fileName = base64_encode($name) . '.' . $extension; // пат до фајлот $path = storage_path() . '\\upload\\' . Session::get('index') . '\\' . $fileName; if (!File::exists($path)) { // фајловите се чуваат во storage/upload/brIndeks/base64(filename).extension $file->move(storage_path('upload/' . Session::get('index')), $fileName); return ['success' => true, 'message' => 'Upload successful.', 'deleteUrl' => action('FileController@delete', [$file])]; } else { return ['success' => false, 'message' => 'File with that name already exists!', 'deleteUrl' => action('FileController@delete', [$file])]; } }); } else { abort(404); } }