如何使图像上传成为必需

时间:2016-11-17 14:43:26

标签: php joomla image-uploading

如何强制/要求此部分代码?代码没有简单的图像上传字段。它来自joomla组件。我已经尝试过指定属性" required"与常规的html上传字段一样,但这没有用。

<section class="block" id="gallery">
                <h2><?php echo JText::_('COM_BT_PROPERTY_GALLERY');?></h2>
                <div class="center">
                    <div class="form-group"> 
                     <?php
                    if ($this->params->get('fe_upload_type', 1) == 1) {
                        echo $this->loadTemplate('images_flash');
                    } else {
                        echo $this->loadTemplate('images_simple');
                    }
                    ?>
                    <?php
                        $params = new JRegistry();
                        if ($this->item->params) {
                            $params->loadArray($this->item->params);
                        }
                        $thumb_height = $params->get('thumb_height', $this->params->get("thumb_height", 180));
                        $thumb_width = $params->get('thumb_width', $this->params->get("thumb_width", 336));
                        if ($thumb_height > 100) {
                            $thumb_width = floor($thumb_width * 100 / $thumb_height);
                            $thumb_height = 100;
                        }
                        $thumbimgprocess = $this->params->get('thumbimgprocess', $this->params->get("thumbimgprocess", 1));
                        ?>
                        <ul id="sortable">
                        <?php
                            if (is_array($this->images)) {

                                foreach ($this->images as $image) {
                        ?>
                            <li title="Double-click to make default image"
                                <?php if ($image->default) echo 'class="default_image"' ?>><input class="input-default"
                                    <?php if ($image->default) echo 'checked="checked"' ?> title="Make default"
                                    name="default_image" type="radio" value="<?php echo $image->filename ?>" /> <img
                                class="img-thumb"
                                src="<?php echo JURI::root() . $path . '/' . $this->item->id . '/' . ($this->params->get('thumbimgprocess', 1) == -1 ? 'original' : 'thumb') . '-' . $image->filename; ?>" />
                                <input type="hidden" name="image_id[]" value="<?php echo $image->id ?>" /> <?php if ($image->youembed != '') {
                                                    ?>

                                <img class="img_video" src="../components/com_bt_property/assets/img/video.png" /> <?php
                                            }
                                            ?>
                                <input type="hidden" name="image_filename[]" value="<?php echo $image->filename ?>" /> <br />
                                <a href="javascript:void(0)" class="edit" onclick="editImage(this)"><?php echo JText::_('COM_BT_PROPERTY_EDIT');?></a> <a
                                href="javascript:void(0)" class="remove" onclick="removeImage(this)"><?php echo JText::_('COM_BT_PROPERTY_REMOVE');?></a>
                            </li>
                            <?php
                                }
                                ?>
                            <input type="hidden" id="property-hidden" name="video" value="<?php echo htmlspecialchars(json_encode($this->images)); ?>" />
                        <?php
                            }
                            ?>

                        </ul>
                        <a href="#" class="button" onclick="return removeAll()"><?php echo JText::_('COM_BT_PROPERTY_CLEAR_ALL');?></a>
                    </div>
                </div>
                <p style = "color:red;">
            "Note: files must not contain any form of contact details; names, phone no, email, address, company, website and so on. As designs with such content will not be approved for posting"
            </p>
            </section>

1 个答案:

答案 0 :(得分:0)

我终于找到了链接到上面代码的简单图像上传按钮的源代码。我所要做的就是在关闭(&gt;)文件输入标记之前照常指定。