/** * Uploads a file to associate to an item * * @return unknown_type */ function addfile($fieldname = 'createproductfile_file', $path = 'products_files') { Tienda::load('TiendaFile', 'library.file'); $upload = new TiendaFile(); // handle upload creates upload object properties $upload->handleUpload($fieldname); // then save image to appropriate folder if ($path == 'products_files') { $path = Tienda::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_TIENDA_MOVE_FAILED_FROM'), $upload->file_path, $dest)); return false; } $upload->full_path = $dest; return $upload; }