douya8978 2016-11-19 10:22
浏览 20
已采纳

使用PHP永久编辑HTML文件

I am building a blogging website and I am facing troubles when I try to upload a photo. I need the photo to be pasted in the webpage. I know that javascript can do that, but it only affects the current session of the webpage. I need to permanently embed that image into the webpage as a child of this div element, for example:

<div id="img-wrapper"></div>

Everything is OK with PHP file uploads. How can I do that with PHP?

  • 写回答

1条回答 默认 最新

  • dsa5211314 2016-11-19 10:26
    关注

    I assume its not an advisable solution as it increases the page size, but you can do this in the following manner:-

    Some examples:

    HTML:

    <img alt="Embedded Image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." />
    

    CSS:

    div.image {
      width:100px;
      height:100px;
      background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA...);
    }
    

    Here is a sample code

    https://jsfiddle.net/casiano/xadvz/

    For an online image to base 64 encode Click here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助