您好,我如何通过模式将图像的值传递到另一个页面?当我单击编辑按钮时,将弹出一个模式,获取的所有数据都在其中,在单击"is"后,它将把表单中的所有数据传递到另一个页面。我是 php 新手,正在开始学习它。有人可以给我一些建议吗?
这是我在模式中的表单。
<form method="POST" enctype="multipart/form-data" action ="edit2.php?newsid=<?=$row['news_id']?>">
<div class="form-group">
<label for="title">News Title</label>
<input type="text" name="titles" class="form-control title" id="title" placeholder="News Title" value="<?php echo $row['news_title']; ?>">
</div>
<div class="form-group">
<label for="date">Date</label>
<input type="text" name="dates" class="form-control date" id="date" placeholder="Date" value="<?php echo $row['news_date']; ?>"s>
</div>
<div class="form-group">
<label for="content">News Content</label>
<textarea class="form-control content" name="contents" rows="5" id="content"><?php echo $row['news_content']; ?></textarea>
</div>
<img id="blah" src="<?php echo $row['news_image']; ?>" width="200px" height="140px"/>
<input id="image" name="image" class="fileupload" type="file" accept="image/*"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class='btn btn-info left-margin'>Yes</a>
</form>
这里是edit2.php。这是我传递图像值并对其进行编辑的位置。
<?php
include_once('connection.php');
$newsid = $_GET['newsid'];
$title = $_POST['titles'];
$date = $_POST['dates'];
$content = $_POST['contents'];
if(isset($newsid)){
$title = $_POST['titles'];
$date = $_POST['dates'];
$content = $_POST['contents'];
$sql ="UPDATE news SET news_title ='$title', news_date ='$date', news_content = '$content', news_image = '$newsimage' WHERE news_id = '$newsid'";
mysqli_query($con, $sql);
}
?>
最佳答案
文件上传与使用 f.e. 的普通“文本”上传有点不同。一个<input type="text">
。不同之处在于,主要是出于安全考虑,它被包装到 protected FormData 对象中。
正常<input type="text">
可使用 $_POST['somename']
访问。可以使用 $_FILES
访问文件命令。
可以在此处找到有关使用 PHP 处理文件的更简短说明: http://php.net/manual/en/reserved.variables.files.php
也许更有用的文章是这样的: http://www.w3schools.com/php/php_file_upload.asp
玩得开心!
最诚挚的问候,
关于javascript - 将图像的值通过modal传递到另一个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38287522/