标签:func item class ram path append with open 文件 form表单
文件上传及预览 Form提交 Ajax 上传文件 时机: 如果发送的[文件]:-》iframe, jQurey(),伪Ajax 预览 import os img_path = os.path.join(‘static/img‘, fafafa.name) with open(img.path, ‘wb‘) as f: for item in fafafa.chunks(): f.write(item) function iframeSubmit(){ $(‘#ifm1‘).load(function(){ var test = $(‘#ifm1‘).contents().find(‘body‘).text(); var obj = JSON.parse(text); $(‘#preview‘).empty(); var imgTag = document.createElement(‘img‘); imgTag.src = ‘/‘ +obj.data; $(‘#preview‘).append(imgTag); #给div添加一个imgTag标签 }) } input onchange = ‘changeUpload()‘ function changeUpload(){ $(‘#ifm1‘).load(function(){ var test = $(‘#ifm1‘).contents().find(‘body‘).text(); var obj = JSON.parse(text); $(‘#preview‘).empty(); var imgTag = document.createElement(‘img‘); imgTag.src = ‘/‘ +obj.data; $(‘#preview‘).append(imgTag); #给div添加一个imgTag标签 }) #(‘#fm1‘).submit(); }
标签:func item class ram path append with open 文件 form表单
原文地址:https://www.cnblogs.com/Liang-jc/p/9273085.html