public function handle_upload()
 {
     $file = $_FILES['Filedata'];
     App::import("Vendor", "UploadServer", array("file" => "UploadServer.php"));
     $ext = pathinfo($file['name'], PATHINFO_EXTENSION);
     $u = new UploadServer();
     $tmp_file = $u->moveUpload($file);
     $file_name = String::uuid() . "." . $ext;
     if ($u->pushUpload($tmp_file, $file_name)) {
         $this->loadModel("MediaFileUpload");
         $this->MediaFileUpload->create();
         $this->MediaFileUpload->save(array("file_name" => $file_name, "name" => $file['name'], "model" => "BerricsRecord", "foreign_key" => base64_decode($_POST['berrics_record_id']), "user_id" => $this->user_id_scope, "file_status" => "pending"));
         die("1");
     } else {
         die("0");
     }
 }
 public function handle_upload()
 {
     $file = $_FILES['Filedata'];
     App::import("Vendor", "UploadServer", array("file" => "UploadServer.php"));
     $ext = pathinfo($file['name'], PATHINFO_EXTENSION);
     $u = new UploadServer();
     $tmp_file = $u->moveUpload($file);
     $file_name = String::uuid() . "." . $ext;
     if ($u->pushUpload($tmp_file, $file_name)) {
         $this->loadModel("MediaFileUpload");
         $this->MediaFileUpload->create();
         $this->MediaFileUpload->save(array("file_name" => $file_name, "name" => $file['name'], "notes" => $this->request->params['pass'][1], "model" => "YounitedNationsEventEntry", "foreign_key" => $this->request->params['pass'][2], "user_id" => $this->user_id_scope));
         die("1");
     } else {
         die("0");
     }
 }
 public function test()
 {
     if (count($this->request->data) > 0) {
         $us = new UploadServer();
         $file = $this->request->data['MediaFileUpload']['test'];
         $tmp_path = $us->moveUpload($file);
         if (!$tmp_path) {
             return $this->cakeError("error500", "No temp file brosky");
         }
         $file_name = String::uuid() . "." . pathinfo($file['name'], PATHINFO_EXTENSION);
         if (!$us->pushUpload($tmp_path, $file_name)) {
             return $this->cakeError("error500", "Could Not SFTP to UPLAOD server");
         }
         //save the new file
         $this->loadModel("MediaFileUpload");
         $this->MediaFileUpload->create();
         $this->MediaFileUpload->save(array("file_name" => $file_name, "user_id" => $this->Auth->user("id"), "model" => "YounitedNationsEntry", "foreign_key" => 2));
     }
 }