Ejemplo n.º 1
0
 public function uploadFiles($userId, $projectId, Request $request)
 {
     $path = 'files/projects/' . $projectId;
     $destinationPath = public_path($path);
     if (!File::exists($destinationPath)) {
         File::makeDirectory($destinationPath, 0777, true);
     }
     foreach ($request->file('files') as $file) {
         $fileName = $file->getClientOriginalName();
         $data['project_id'] = $projectId;
         $data['user_id'] = $userId;
         $data['name'] = $fileName;
         $data['path'] = $path . '/' . $fileName;
         if (ProjectFiles::create($data)) {
             $file->move($destinationPath, $fileName);
         }
     }
 }
Ejemplo n.º 2
0
 public function fileSave()
 {
     if (\Request::ajax()) {
         //  if (Input::hasFile('file')) {
         $project_id = Input::input('postprojectid');
         $file_description = Input::input('file_description');
         $file_id = Input::input('file_id');
         $pro_file = ProjectFiles::where('id', '=', $file_id);
         $new_project_file = array("file_des" => $file_description);
         // project  ανοιχτο
         $pro_file->update($new_project_file);
         //            $file = Input::file('file');
         //            $project_id = Input::input('file-project-id');
         //            $name = $file->getClientOriginalName();
         //            $file->move(
         //                base_path() . '/public/projectfiles/', $project_id.'_'.$name
         //            );
         //
         //            $project_files= new ProjectFiles();
         //            $project_files->file_name = $name;
         //            $project_files->file_path = base_path() . '/public/projectfiles/'. $project_id.'_'.$name;
         //            $project_files->project_id = $project_id;
         //
         //            $project_files->save();
         //  $project->filepath = base_path() . '/public/projectfiles/' . $fileName;
         // $project->save();
         //    };
         echo json_encode(array('pro_file' => $pro_file));
     }
 }