/**
  * Upload files to cloudinary
  *
  */
 public function upload(UploadRequest $request)
 {
     $judul_file = $request->get('judul');
     $gambar = $request->file('gambar');
     $nama_file = Str::slug($judul_file);
     $upload = \Cloudinary\Uploader::upload($gambar, array("public_id" => $nama_file));
     return redirect()->to($nama_file);
 }
예제 #2
0
 public function updateFile(UploadRequest $request)
 {
     $path = public_path('upload/file');
     $input = json_decode($request->get('data'));
     $upload = Upload::find($input->id_download);
     if ($request->hasFile('file')) {
         $upload->judul_file = $input->judul_file;
         $upload->author = $this->auth->user()->nama_pegawai;
         $upload->nama_file = $request->file('file')->getClientOriginalName();
         $request->file('file')->move($path, $upload->nama_file);
         if ($upload->save()) {
             return response()->json(array('success' => TRUE));
         }
     }
 }
예제 #3
0
 public function upload(UploadRequest $request)
 {
     $type = $request->input('type');
     if ($request->ajax()) {
         //确认文件是否有上传
         if ($request->hasFile('file')) {
             //code..
             $file = $request->file('file');
             if (!$file->isValid()) {
                 $result = ['status' => 'failed', 'msg' => '上传文件无效!'];
             } else {
                 $extension = $file->getClientOriginalExtension();
                 //取得上传文件的后缀名
                 $path = 'uploads/' . $type . '/';
                 $savePath = $path . date('Ymd', time());
                 File::exists($savePath) or File::makeDirectory($savePath, 0755, true);
                 $saveFileName = uniqid() . '_' . $type . '.' . $extension;
                 //函数基于以微秒计的当前时间,生成一个唯一的 ID。
                 $file->move($savePath, $saveFileName);
                 $fullFileName = $savePath . '/' . $saveFileName;
                 $result = ['status' => 'success', 'msg' => '上传成功!', 'path' => $fullFileName];
             }
         } else {
             $result = ['status' => 'failed', 'msg' => '请选择上传文件!'];
         }
         return $result;
     }
 }
 public function postIndex(UploadRequest $request)
 {
     $orginal = $request->file('picture');
     $picture = new Picture();
     $picture->save();
     $tempname = uniqid('sotm-') . '.' . $orginal->getClientOriginalExtension();
     $orginal->move('/tmp', $tempname);
     $picture->init("/tmp/{$tempname}");
     $picture->addLocation($request);
     unlink("/tmp/{$tempname}");
 }
 /**
  * Uploads files to the specified batch.
  *
  * @param UploadRequest $request
  * @param string $uuid
  */
 public function perform(UploadRequest $request, $uuid)
 {
     // Locate the batch
     $batch = $this->batch->locate($uuid);
     // Retrieve the file from the request
     $file = $request->file('file');
     // Double check the file instance
     if ($file instanceof UploadedFile) {
         // Validate file name length
         if (strlen($file->getClientOriginalName()) > 70) {
             abort(422, 'File name is too large');
         }
         // Generate a file name with UUID and its extension
         $name = uuid() . "." . $file->getClientOriginalExtension();
         // Get the storage path
         $path = $batch->uuid . DIRECTORY_SEPARATOR . $name;
         // Move the file into storage
         Storage::put($path, file_get_contents($file->getRealPath()));
         // Add the file to the batch
         $batch->addFile($file->getClientOriginalName(), $file->getClientMimeType(), $file->getClientSize(), $path);
     } else {
         abort(404);
     }
 }
예제 #6
0
 public function uploadFiles(UploadRequest $request)
 {
     $destinationPath = 'uploads';
     $extension = $request->file('file')->getClientOriginalExtension();
     $fileName = rand(11111, 99999) . '.' . $extension;
     $upload_success = $request->file('file')->move($destinationPath, $fileName);
     if ($upload_success) {
         return Response::json(array('success' => true, 'message' => 'Successfully uploaded file.'), 200);
     } else {
         return Response::make(array('success' => false, 'message' => 'Error while uploading file.'), 400);
     }
 }
예제 #7
0
 public function upload($directory, Requests\UploadRequest $request)
 {
     try {
         $imageName = $request->file('image')->getClientOriginalName();
         $extension = $request->file('image')->getClientOriginalExtension();
         if ($extension != 'pdf') {
             $image = Image::make($request->file('image')->getRealPath());
             $image->widen(500);
             $image->save(public_path() . '/docs/temp/' . $imageName);
         } else {
             $request->file('image')->move('docs/temp', $imageName);
         }
         try {
             rename(public_path() . '/docs/temp/' . $imageName, public_path() . '/docs/' . $directory . '/' . $imageName);
             return response()->json(['success' => true]);
         } catch (\Exception $e) {
             return response()->json(['success' => false]);
         }
     } catch (\Exception $e) {
         echo $e->getMessage();
     }
 }
 public function updateFile(UploadRequest $request)
 {
     $path = public_path('upload/file');
     $input = json_decode($request->get('data'));
     $upload = Upload::find($input->id_download);
     if ($request->hasFile('file')) {
         // File Delete By Agus Cahyono
         $file_lama = DB::table('tbl_download')->select('nama_file')->where('id_download', $input->id_download)->first();
         File::delete('upload/file/' . $file_lama->nama_file);
         $upload->judul_file = $input->judul_file;
         $upload->author = $this->auth->user()->nama_pegawai;
         $upload->nama_file = Str::random(25) . "." . $request->file('file')->getClientOriginalExtension();
         $request->file('file')->move($path, $upload->nama_file);
         if ($upload->save()) {
             return response()->json(array('success' => TRUE));
         }
     }
 }
예제 #9
0
 /**
  * Save several journal entries
  *
  * @return Response
  */
 public function bulk_store(UploadRequest $request)
 {
     $csv = $request->input('csv');
     $csv_upload = $request->file('csv')->move(base_path() . '/public/', $csv);
     $this->_extract_csv_data($csv_upload);
     foreach ($this->_csv_rows as $row) {
         // pass through logger request validation/save methods
         $logger_request = new LoggerRequest();
         $logger_request->replace(['user' => \Auth::user(), 'date' => \Carbon\Carbon::createFromFormat('m.d.y', $row['date'])->toDateTimeString(), 'tempo' => $row['tempo'], 'entry' => $row['entry'], 'bulk' => true]);
         $logger_request->setContainer(app());
         $logger_request->validate();
         $this->store($logger_request);
     }
     $this->_calculate_tempo();
     return $this->_redirect();
 }
예제 #10
0
 function upload(UploadRequest $request)
 {
     $user = Auth::user();
     // If this user already has at least 3 pending uploads, tell them to wait
     if ($user->uploads->where('status', 'pending')->count() >= 3) {
         $request->session()->flash('error', "You've already uploaded 3 files. Please wait for an admin to review them before uploading more.");
         return redirect('/profile');
     }
     // Create upload folder if it doesn't exist
     if (!file_exists(public_path() . '/files/user')) {
         mkdir(public_path() . '/files/user', 0755, true);
     }
     // Make sure the original filename is sanitized
     $file = pathinfo($request->file('file')->getClientOriginalName());
     $fileName = preg_replace('/[^a-z0-9-_]/', '', $file['filename']) . "." . preg_replace('/[^a-z0-9-_]/', '', $file['extension']);
     // Move file to uploads directory
     $fileName = time() . '-' . $fileName;
     $request->file('file')->move(public_path() . '/files/user', $fileName);
     // Create a new user upload
     $upload = new UserUpload();
     $upload->file = $fileName;
     $upload->status = 'pending';
     $upload->user_id = $User->id;
     $upload->save();
     // Save additional form data
     $input = $request->all();
     $upload->update($input);
     event(new FileUploaded($upload));
     $request->session()->flash('success', 'Your file was uploaded.');
     return redirect('/profile');
 }