php - 我如何在另一个中显示另一个图像或文本
问题描述
我遇到了一些 PHP 问题。我想上传一张图片,显示它,点击“处理”后,在页面的另一边显示一些东西。例如代码,我只想显示“你好”。当我尝试这样做时,它会清除上传的图像。任何指向正确方向的指针?
非常感激。
代码:
<!DOCTYPE html
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
</head>
<body>
<div class="row">
<aside id="left">
<form action="" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="file_to_upload" id="file_to_upload">
<input type="submit" name="submits" id="upload_button" value="upload">
</form>
<div id="uploaded_pic">
<?php
if(isset($_POST['submits']))
{
$filepath = "images/upload" . $_FILES["file_to_upload"]["name"];
if(move_uploaded_file($_FILES["file_to_upload"]["tmp_name"], $filepath))
{
echo "<img src=".$filepath." height=640 width=480 />";
}
else
{
echo "Problem uploading";
}
}
?>
</div>
<div id="process-button">
<form action="" method="POST" name="processing">
<input type="submit" name="process_button" id="process_button" value="process">
</form>
</div>
</aside>
<aside id="right">
<?php
if (array_key_exists('process_button',$_POST))
{
echo "hello";
}
?>
</div>
</aside>
</div>
</body>
</html>
解决方案
对于因类似问题或纯粹兴趣而担心的任何人-在此代码中,清除屏幕的问题是由第二种形式引起的。提交后就清屏了。所以我用一个简单的按钮和 onevent 处理程序替换了表单,现在它工作正常。
推荐阅读
- android - 与收到的相比,Android FCM 发送的通知总数要高得多
- python - 如何只计算字典中的单词,同时返回字典键名的计数
- bash - 在bash中为变量字符串赋值
- python - 安装osmnx时出错(必须指定GDAL API版本)问题
- javascript - 使用 html 画布在没有库的 JS 中使用鼠标单击剪切形状
- elasticsearch - 使用 ELK 在 grafana 中可视化 Nginx 日志
- openid - Scope 和 Claims 参数不会从 Keycloak 服务器转发到另一个 OIDC 提供程序
- ubuntu-18.04 - 你如何在 Grafana 中嵌入视频?
- ios - Xcode 11.2 swift 13.2 发生 SSL 错误,无法与服务器建立安全连接
- java - 通过自定义注释根据参数名称获取参数值