怎么把图片存入mysql数据库,使用html读取出来

怎么把图片存入mysql数据库,使用html读取出来,第1张

读出二进制,转化成流,然后write到页面上

byte[] blob = userinfo.getPhoto()

if(blob!=null){

response.reset() response.setContentType("image/"+dat) OutputStream toClient = response.getOutputStream() try {toClient.write(blob) } catch (Exception e) {e.printStackTrace() }finally{toClient.flush() toClient.close() } response.flushBuffer() }

数据库

byte[] bFile = new byte[(int) files[0].length()]FileInputStream fileInputStream = new FileInputStream(files[0])fileInputStream.read(bFile)fileInputStream.close()userinfo.setPhotoname(photoName[0])userinfo.setPhoto(bFile)

userdao.save(userinfo)

我这个是java的,不知道和你的一不一样

写绝对路径

ie和firefox 的路径格式不一样。

由于安全机制,IE7+和火狐等浏览器不支持显示本地图片

好像在路径钱加file:///好像就好了

<html>

<body background="file:///D:\\1.png">

</body>

</html>


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9577133.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存