因为要用到一个通用的上传,
所以直接把以前写的一个上传程序Copy过来了,
想着传递两个参数,input的名称和form的名称,然后就能自动把值返回过去了,
在其他项目中直接调用这个就好了,
结果写好后,在本地测试正常,代码如下:
<form name="myform" action="MyJsp">
<input type=text name="pic">
<iframe src="Upload?form=myform&inputName=pic"></iframe>
</form>
<script>parent.document.form名称.input名称.value='path路径'</script>
<iframe src="http://www.xxx.com/UploadFile/Upload?form=myform&inputName=pic"></iframe>
<form name="myform" action="MyJsp">
<input type=text id=text1>
<iframe src="http://www.xxx.com/UploadFile/Upload" id=t1></iframe>
<script for=t1 event=onload>
text1.value=window.status;
</script>
</form>
<script>window.status="Path上传后的路径";</script>
所以直接把以前写的一个上传程序Copy过来了,
想着传递两个参数,input的名称和form的名称,然后就能自动把值返回过去了,
在其他项目中直接调用这个就好了,
结果写好后,在本地测试正常,代码如下:




然后在处理完整个上传流程后,用

来自动返回上传路径到input输入框,
当然,这样写,没有错,而且我一直都是这样来用的,
但是这次出问题了,
我在本机都正常,值能正确返回,
但是同事在另外的电脑上用的时间就出问题了,
因为所在项目不同,需要用完整路径来iframe进来,
也就是改成了这个样子,

HO,问题出来了,上传后提示错误,拒绝访问,
晕,怎么会拒绝访问,赶紧GG了下,
发现有个跨域访问的问题,IE默认级别禁止了跨域访问,
好像是这样,值回不来了,么办法,又GG了下,
找到另外一种方法,
这个挺爽,也不需要什么form名称之类的。:)
修改后的完整代码如下:







在上传流程完成后,

这样就可以了,比开始的方法简便的多了。:)
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步