为什么我上传的图片没有';我的php页面上没有显示?
以下是上载页面的主页:为什么我上传的图片没有';我的php页面上没有显示?,php,html,Php,Html,以下是上载页面的主页: <form id="form1" method="post" action="display.php" enctype="multipart/form-data" id="pro_image"> <input type='file' onchange="readURL(this);" name="image" id="image"/> <br><img id="blah" src="profile pic.jpg"
<form id="form1" method="post" action="display.php" enctype="multipart/form-data" id="pro_image">
<input type='file' onchange="readURL(this);" name="image" id="image"/>
<br><img id="blah" src="profile pic.jpg" alt="your image" width="160px" height="120px"/><br/>
</form>
与图像显示页面(display.php)脚本合并:
任何人都可以帮助我指出display.php
上的实际问题,并纠正我的脚本?图像在页面上没有按预期显示
display.php的输出如上所示:
你忘了
这里
<img src="<?php echo $dir.$name; ?>" width="100" height="100"/>
“width=“100”height=“100”/
您的display.php
文件是一个php文件,您可以尝试显示变量数据,而不在该文件中进行回显。请使用它
<img src="<?php echo $dir.$name; ?>" width="100" height="100"/>
嗯,你试过用PHP标签包装你的图像吗?“width=“100”height=“100”/>@Ninsuo,我试过了,但没有成功,页面显示框,框内有小的默认图像,因为我们总是看到实际图像在某个论坛或个人资料中没有显示出来,我尝试过你的建议,但是在firefox中使用failuse inspect元素并查看此图像标记的路径。@Yogesh Suthar我检查了将图像文件移动到其中的目录,发现该图像文件不在该目录中。这是否意味着将文件移动到
上载目录的php脚本失败?@JCChan查看的文件夹权限上传
文件夹。使其可写。@Yogesh Suthar如何使其可写?@JCChan也许src没有得到正确的路径。检查您的上传文件夹是否靠近display.php文件。您使用的平台是windows还是linux?让我们通过输出显示上传时出现错误。
…这意味着什么?是的,现在您遇到了问题。你的问题是上传的不是html代码。如何使用绝对路径?为什么我直接进入首页的链接?不是吗
<img src="<?php echo $dir.$name; ?>" width="100" height="100"/>
move_uploaded_file($tmp,$dir.$name) or die("There is error in uploading");