如何将现有图像值放入$_FILES数组


How to put an existing image value to $_FILES array

我有一个表单,其中有一些文本字段和图像字段。用户可以编辑此表单。我可以将现有图像提取到表单中,他们可以在表单中看到图像,但当他们不做任何事情就提交时,我无法在$_FILES数组中看到图像。

如何将此图像放入$_FILES数组。

<div class="md-card-content">
    <h3 class="heading_a uk-margin-small-bottom">
        Upload Image
    </h3>
    <input 
         type="file" 
         id="input-file-b" 
         name='gallery_image[<?php echo $counter; ?>]' 
         data-default-file="<?php echo $image['image_path']; ?>" 
         class="dropify">
</div>

文件不支持值属性,因此不可能。

您可以添加一个条件来查看$_FILES是否是有效的数组并具有数据或者在做任何事情之前不要。

If (is_array($_FILES) and count($_FILES) > 0) {
    //save the new file and delete old file
} else {
   //Need not to do anything as the file is already saved in your system
}