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()); } }
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()); } }