本文介绍了基地64代码不工作...不显示数据库中的图像在PHP的PHP的MySQL形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 image第一张图显示了我的剪贴画并显示了我的数据库外观 < form action =login.phpmethod =postenctype =multipart / form-data> < br>< br>< br> 选择图片:< input type =filename =imagesize =40id =image> < br><小>必须小于512kb< / small> < br>< br> < input type =submitname =submitvalue =submit> < / form> 没有收到任何错误..仍然无法正常工作... p> <?php if(isset($ _ POST ['submit'])) { if(getimagesize($ _ FILES ['image'] ['tmp_name'])== FALSE) { echo< script>请插入图片< /脚本>中; exit(); } else { $ image = addslashes($ _ FILES ['image'] ['tmp_name']); $ name = addslashes($ _ FILES ['image'] ['name']); $ image = file_get_contents($ image); $ image = base64_encode($ image); saveimage($ name,$ image); } } displayimage(); 函数saveimage($ name,$ image) { $ con = @ mysqli_connect(localhost,root,,work); ry =insert into pics(name,image)values('$ name','$ image'); $ result = mysqli_query($ con,$ qry); if($ result) { echo< br> image uploaded; } 其他 {回显< br>图片未上传; $ b函数displayimage() { $ con = @ mysqli_connect(localhost,root, ,工作); $ qry =select * from pics; $ result = mysqli_query($ con,$ qry); **我现在的问题在于此,但我不确定.. * * pre $ while($ row = mysqli_fetch_array($ result)) { $ img_type ='png或jpg'; echo< img height ='250'width ='250'src ='data:image /\".$ img_type。; base64','。$ row [1]。'> ; } mysqli_close($ con); } ?> 不知道该怎么做..请帮助我们 解决方案 echo< img height ='250'width ='250'src ='data :图片/ 。 $ img_type。 ; base64,。 $ row [1]。 '>; 尝试用@showdev的建议替换您的代码 image 1st shows my scrren and shows my database looks <form action="login.php" method="post" enctype="multipart/form-data"> <br><br><br> select image:<input type="file" name="image" size="40" id="image"> <br><small> must be less than 512kb </small> <br><br> <input type="submit" name="submit" value="submit"> </form>not getting any error.. still not working... <?php if(isset($_POST['submit'])) { if(getimagesize($_FILES['image'] ['tmp_name'])==FALSE) { echo "<script> please insert the image </script>"; exit(); } else { $image=addslashes($_FILES['image'] ['tmp_name']); $name=addslashes($_FILES['image'] ['name']); $image= file_get_contents($image); $image= base64_encode($image); saveimage($name,$image); } } displayimage(); function saveimage($name,$image) { $con=@mysqli_connect("localhost","root","","work"); $qry="insert into pics( name, image) values('$name','$image')"; $result= mysqli_query($con,$qry); if($result) { echo"<br> image uploaded"; } else { echo"<br> image not uploaded"; } } function displayimage() { $con=@mysqli_connect("localhost","root","","work"); $qry= "select* from pics"; $result= mysqli_query($con,$qry);**i thing the problem is here in this while.. but i am not sure.. ** while($row = mysqli_fetch_array($result)) { $img_type = 'png or jpg'; echo"<img height='250' width='250' src='data:image/".$img_type.";base64', '".$row[1]."' >"; } mysqli_close($con); } ?>dont know what to do.. please help me guys 解决方案 echo "<img height='250' width='250' src='data:image/" . $img_type . ";base64," . $row[1] . "' >";Try replace your code with this as suggest by @showdev 这篇关于基地64代码不工作...不显示数据库中的图像在PHP的PHP的MySQL形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-03 14:57