JoomCoder-com / JoomCCK

Advanced Web Application Builder & Content Construction Kit (CCK) for Joomla CMS
https://www.joomcoder.com
GNU General Public License v2.0
10 stars 1 forks source link

Field Image: Upload fails "open_basedir restriction" #190

Closed LordHelmchen666 closed 4 months ago

LordHelmchen666 commented 4 months ago

When open_basedir is set in PHP config then upload fails. If i do not set then upload works. could not save. Error: Joomla\Filesystem\Folder::create: Path not in open_basedir paths

I think it is this code components/com_joomcck/fields/image/image.php from line 176

       $dest  = $params->get('general_upload') . DIRECTORY_SEPARATOR . $subfolder . DIRECTORY_SEPARATOR;
                $index = '<html><body></body></html>';
                if(!is_dir($dest))
                {
                    \Joomla\Filesystem\Folder::create($dest, 0755);
                    \Joomla\Filesystem\File::write($dest . DIRECTORY_SEPARATOR . 'index.html', $index);
                }

                $dest .= $date . DIRECTORY_SEPARATOR;
                if(!is_dir($dest))
                {
                    \Joomla\Filesystem\Folder::create($dest, 0755);
                    \Joomla\Filesystem\File::write($dest . DIRECTORY_SEPARATOR . 'index.html', $index);
                }

                $filename = $time . '_' . md5($file['name']);
                $dest .= \Joomla\Filesystem\File::stripExt($filename) . '.' . $ext;

                if(\Joomla\Filesystem\File::upload($file['tmp_name'], JPATH_ROOT . DIRECTORY_SEPARATOR . $dest))
LordHelmchen666 commented 4 months ago

There needs to be a full path in create and write to work . Just tested on my system with changed code to

       $dest  = $params->get('general_upload') . DIRECTORY_SEPARATOR . $subfolder . DIRECTORY_SEPARATOR;
                $index = '<html><body></body></html>';
                if(!is_dir($dest))
                {
                    \Joomla\Filesystem\Folder::create(JPATH_ROOT . DIRECTORY_SEPARATOR . $dest, 0755);
                    \Joomla\Filesystem\File::write(JPATH_ROOT . DIRECTORY_SEPARATOR . $dest . DIRECTORY_SEPARATOR . 'index.html', $index);
                }

                $dest .= $date . DIRECTORY_SEPARATOR;
                if(!is_dir($dest))
                {
                    \Joomla\Filesystem\Folder::create((JPATH_ROOT . DIRECTORY_SEPARATOR . $dest, 0755);
                    \Joomla\Filesystem\File::write((JPATH_ROOT . DIRECTORY_SEPARATOR . $dest . DIRECTORY_SEPARATOR . 'index.html', $index);
                }

                $filename = $time . '_' . md5($file['name']);
                $dest .= \Joomla\Filesystem\File::stripExt($filename) . '.' . $ext;

                if(\Joomla\Filesystem\File::upload($file['tmp_name'], JPATH_ROOT . DIRECTORY_SEPARATOR . $dest))