/** * Uploads a file to associate to an item * * @return unknown_type */ function addfile($fieldname = 'createproductfile_file', $path = 'products_files') { Citruscart::load('CitruscartFile', 'library.file'); $upload = new CitruscartFile(); // handle upload creates upload object properties $upload->handleUpload($fieldname); // then save image to appropriate folder if ($path == 'products_files') { $path = Citruscart::getPath('products_files'); } $upload->setDirectory($path); $dest = $upload->getDirectory() . DS . $upload->getPhysicalName(); // delete the file if dest exists if ($fileexists = JFile::exists($dest)) { JFile::delete($dest); } // save path and filename or just filename if (!JFile::upload($upload->file_path, $dest)) { $this->setError(sprintf(JText::_('COM_CITRUSCART_MOVE_FAILED_FROM'), $upload->file_path, $dest)); return false; } $upload->full_path = $dest; return $upload; }