예제 #1
0
파일: file.php 프로젝트: eric116/BotQueue
 public function local()
 {
     // Local file upload
     try {
         if (empty($_FILES['file']) || !is_uploaded_file($_FILES['file']['tmp_name'])) {
             throw new Exception("Something went wrong with uploading this file. The file may be too large to upload.");
         }
         $tmp_file = $_FILES['file'];
         $dst = STORAGE_PATH . "/uploads/" . $tmp_file["name"];
         $this->ensureGoodFile($tmp_file);
         if (file_exists($dst)) {
             unlink($dst);
         }
         // Create the directory structure if it doesn't exist
         if (!is_dir(dirname($dst))) {
             mkdir(dirname($dst), 0777, true);
         }
         rename($tmp_file["tmp_name"], $dst);
         $file = FileUploadHandler::fromName("uploads/" . $tmp_file["name"]);
         Activity::log("uploaded a new file called " . $file->getLink() . ".");
         //send us to step 2.
         $this->forwardToUrl("/job/create/file:{$file->id}");
     } catch (Exception $e) {
         $this->set('megaerror', $e->getMessage());
     }
 }
예제 #2
0
파일: upload.php 프로젝트: eric116/BotQueue
 public function success()
 {
     $this->assertLoggedIn();
     //handle our upload
     try {
         $file = FileUploadHandler::fromName($this->args('key'));
         Activity::log("uploaded a new file called " . $file->getLink() . ".");
         //send us to step 2.
         $this->forwardToUrl("/job/create/file:{$file->id}");
     } catch (Exception $e) {
         $this->setTitle("Upload File - Error");
         $this->set('megaerror', $e->getMessage());
     }
 }