如何在Joomla中添加删除按钮到文件上传


how to add a remove button to file upload in joomla?

我是编码Joomla组件的新手,我正在编写我的第一个组件,并从PHP中的0开始我的知识

在我的组件中,我有 4 个文件上传器(3 个用于图像/pdf/等,1 个用于视频),我想添加一个按钮来删除文件,以防该人不再需要该文件

可以帮助我吗?

下面是表单页面的代码:

<div class="control-group">
            <div class="control-label"><?php echo $this->form->getLabel('video'); ?></div>
            <div class="controls"><?php echo $this->form->getInput('video'); ?></div>
        </div>
            <?php if (!empty($this->item->video)) : ?>
                    <a href="<?php echo JRoute::_(JUri::base() . 'components' . DIRECTORY_SEPARATOR . 'com_product_manager' . DIRECTORY_SEPARATOR . 'video' .DIRECTORY_SEPARATOR . $this->item->video, false);?>">[View File]</a>
            <?php endif; ?>
            <input type="hidden" name="jform[video]" id="jform_video_hidden" value="<?php echo $this->item->video ?>" />                <input type="hidden" name="jform[ordering]" value="<?php echo $this->item->ordering; ?>" />
            <input type="hidden" name="jform[state]" value="<?php echo $this->item->state; ?>" />
            <input type="hidden" name="jform[checked_out]" value="<?php echo $this->item->checked_out; ?>" />
            <input type="hidden" name="jform[checked_out_time]" value="<?php echo $this->item->checked_out_time; ?>" />

您需要询问任何进一步的信息,我会提供

在控制器文件中,您应该添加一个名为 deleteImage 的函数,该函数将从文件系统中删除映像。在布局文件(视图的模板,如"default.php")中,您应该在每个上传的文件旁边添加一个链接,如下所示:

index.php?option=com_pressrelease&task=deleteImage&id=imageId