We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44195
    • 293 Posts
    Hi,

    I'm attempting to extend the modBrowserFileUploadProcessor to upload an image via a Custom Manager Page. I'm passing the path parameter to the processor e.g. (hard coded for the example)

    ,baseParams: {
        action: 'mgr/artworks/upload'
        ,path: '/var/www/mycomponent/assets/components/mycomponent/galleries'
    }
    


    and if I customize the initialize() and process() functions with:
    $this->modx->log(modX::LOG_LEVEL_DEBUG, 'The current value of path is:' . $this->getProperty('path'));
    


    it shows the correct path, however I'm getting an error back when submitting the form saying that
    The specified directory is not a directory.: /var/www/modx/var/www/mycomponent/assets/components/mycomponent/galleries
    


    So, as you can see, it's tacking "/var/www/modx/" on the front of my path somewhere.
    Does anyone have any idea at what point this is happening? Or how to prevent it?
    Hair pulling has ensued.

    Thanks in advance!
      I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
      Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com
      • 44195
      • 293 Posts
      I'm sure this wouldn't be an issue if I were developing within the modx directory, however I've created my own like demonstrated in the doodles tutorial.

        I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
        Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com
        • 44195
        • 293 Posts
        Here's my test processor

        <?php
        include_once MODX_CORE_PATH . 'model/modx/processors/browser/file/upload.class.php';
        
        class MyComponentUploadProcessor extends modBrowserFileUploadProcessor {
        
            public function getLanguageTopics() {
                return array('file');
            }
        
            public function initialize() {
                $path = $this->getProperty('path');
                $this->modx->log(modX::LOG_LEVEL_DEBUG, 'The current value of path is:' . $path);
                // The log shows the path correctly here
                return parent::initialize();
            }
        
            public function process() {
                $this->modx->log(modX::LOG_LEVEL_DEBUG, 'The current value of path is:' . $this->getProperty('path'));
                // The log shows the path is still correct here!
                return parent::process();
            }
        
        }
        return 'MyComponentUploadProcessor';
        


        I really don't understand why or at what point the modx base path is being appended to the beginning of my hard-coded path.
        Has anyone customized the file upload processor before?
        Is there a function I can overload to check the state of the path after process()?

        Thanks again!
          I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
          Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com