摘要
基于传统的HTML5多文件上传采用FormData方式,将文件数据编译成键值对,用异步请求方式上传文件,但是不同浏览器对FormData对象的支持情况并不容乐观,导致不支持FormData的浏览器文件上传失败。该文针对浏览器不支持FormData对象操作,提出在基于浏览器客户端对图片进行Base64编码,将图片转换为字符串提交,在服务器端再对其进行解码后再生成图片文件的通用图片上传方法。
Based on the traditional HTML5 multi-file uploading method, the file data is compiled into key-value pairs and uploaded asynchronously. However, the support of different browsers for FormData objects is not optimistic, which leads to the failure of file uploading in browsers that do not support FormData. In view of the fact that browsers do not support the operation of FormData objects, this paper proposes a general image uploading method based on browser client to encode pictures by Base64, convert pictures to string submission, decode them on the server and regenerate them into picture files.
作者
周岚
ZHOU Lan(Department of information technology,Xuzhou Vocational College of Finance and economics,Jiangsu,Xuzhou 221008,China)
出处
《电脑知识与技术》
2018年第11期106-108,共3页
Computer Knowledge and Technology