我选择了多个图像并在div框中显示预览。当我点击保存按钮时,我想在PHP中使用循环获取图像的信息。在PHP中使用循环获取图像
我尝试回显image_path用于测试目的,但它没有显示任何输出。
HTML表单
<form id="photo-event-form" name="event-photo-gallery-form" class="form-horizontal" method="post" role="form" enctype="multipart/form-data">
<fieldset>
<div class="control-group">
<label class="control-label" for="event_date">Event Photo</label>
<div class="controls">
: <input type="file" class="span3" id="pg_album" name="pg_album" multiple />
<div id="form_button_div" class="form_button_div">
<button id="test" name="pg_Save" type="submit" class="btn btn-primary">Save</button>
<button class="btn">Cancel</button>
</div>
</fieldset>
</form>
PHP保存提交
if (isset($_POST['pg_Save'])) {
$image_path = $_FILES['pg_album'];
$i = 0;
foreach ($Contents as $image_path) {
$i++;
echo $image_path; //display image file path
}
}
?>
'$ Contents'从哪里来? –
@scrowler对不起,这个解决方案我参考了其他问题的答案。我认为这是一个代表$ image_path的变量。 – user3663143