예제 #1
0
파일: file.php 프로젝트: Anon215/filebin
 public function upload()
 {
     $this->muser->require_access("basic");
     $files = getNormalizedFILES();
     if (empty($files)) {
         throw new \exceptions\PublicApiException("file/no-file", "No file was uploaded or unknown error occurred.");
     }
     \service\files::verify_uploaded_files($files);
     $limits = $this->muser->get_upload_id_limits();
     $urls = array();
     foreach ($files as $file) {
         $id = $this->mfile->new_id($limits[0], $limits[1]);
         \service\files::add_uploaded_file($id, $file["tmp_name"], $file["name"]);
         $ids[] = $id;
         $urls[] = site_url($id) . '/';
     }
     return array("ids" => $ids, "urls" => $urls);
 }
예제 #2
0
파일: file.php 프로젝트: Anon215/filebin
 /**
  * Handles uploaded files
  * @Deprecated only used by the cli client
  */
 function do_upload()
 {
     // stateful clients get a cookie to claim the ID later
     // don't force them to log in just yet
     if (!stateful_client()) {
         $this->muser->require_access("basic");
     }
     $ids = array();
     $extension = $this->input->post('extension');
     $multipaste = $this->input->post('multipaste');
     $files = getNormalizedFILES();
     service\files::verify_uploaded_files($files);
     $limits = $this->muser->get_upload_id_limits();
     foreach ($files as $key => $file) {
         $id = $this->mfile->new_id($limits[0], $limits[1]);
         // work around a curl bug and allow the client to send the real filename base64 encoded
         // TODO: this interface currently sets the same filename for every file if you use multiupload
         $filename = $this->input->post("filename");
         if ($filename !== false) {
             $filename = base64_decode($filename, true);
         }
         // fall back if base64_decode failed
         if ($filename === false) {
             $filename = $file['name'];
         }
         $filename = trim($filename, "\r\n\t\v");
         service\files::add_uploaded_file($id, $file["tmp_name"], $filename);
         $ids[] = $id;
     }
     if ($multipaste !== false) {
         $userid = $this->muser->get_userid();
         $ids[] = \service\files::create_multipaste($ids, $userid, $limits)["url_id"];
     }
     $this->_show_url($ids, $extension);
 }