public function download()
 {
     $file = $this->getProperty('file');
     $contents = $this->source->getObjectContents($file);
     @session_write_close();
     header("Content-Type: application/force-download");
     header("Content-Disposition: attachment; filename=\"{$contents['basename']}\"");
     echo $contents['content'];
     die;
 }
Beispiel #2
0
 public function process()
 {
     /* format filename */
     $file = rawurldecode($this->getProperty('file', ''));
     $source = $this->getSource();
     if ($source !== true) {
         return $source;
     }
     $this->source = $this->getProperty('source', 1);
     $fileArray = $this->source->getObjectContents($file);
     if (empty($fileArray)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success('', $fileArray);
 }
Beispiel #3
0
 public function process()
 {
     /* format filename */
     $file = rawurldecode($this->getProperty('file', ''));
     $loaded = $this->getSource();
     if ($loaded !== true) {
         return $loaded;
     }
     if (!$this->source->checkPolicy('delete')) {
         return $this->failure($this->modx->lexicon('permission_denied'));
     }
     $fileArray = $this->source->getObjectContents($file);
     if (empty($fileArray)) {
         $msg = '';
         $errors = $this->source->getErrors();
         foreach ($errors as $k => $msg) {
             $this->addFieldError($k, $msg);
         }
         return $this->failure($msg);
     }
     return $this->success('', $fileArray);
 }