当前位置:网站首页>Sharing of local file upload technology of SAP ui5 fileuploader
Sharing of local file upload technology of SAP ui5 fileuploader
2022-07-27 17:11:00 【Wang Zixi】
When we use SAP UI5 Of FileUploader Control , When uploading local files , The entry of its execution logic , Namely FileUploader.prototype.upload:

First, determine whether the control has been disable:
if (!this.getEnabled()) {
return;
}
SAP UI5 FileUploader The bottom layer can be based on form Of multipart/form-data perhaps XHR There are two technical ways to upload files , This can be seen clearly in the following source code .

use first getDomRef obtain fu_form, That is, the highlighted area in the figure below :
try {
this._bUploading = true;
if (this.getSendXHR() && window.File) {
var aFiles = this.FUEl.files;
if (bPreProcessFiles) {
this._sendProcessedFilesWithXHR(aFiles);
} else {
this._sendFilesWithXHR(aFiles);
}
} else if (uploadForm) {
// In order to do the submit, the action DOM attribute of the inner form should be accurate.
// If there is a change in the passed to the uploadUrl property string, we must ensure that it is
// applied in the DOM and the submit is performed after there is new rendering.
sActionAttr = uploadForm.getAttribute("action");
if (sActionAttr !== this.getUploadUrl()) {
this._submitAfterRendering = true;
} else {
this._submitAndResetValue();
}
}
If the returned object instance is not empty , Instruction use form To submit local code .
Now you are ready to submit the document :_submitAndResetValue
It's called HTML form Native submit Method to submit :
The server returned a File uploaded ok! String :

This string is hidden iframe You can see it in the library :
I can't visit this.oIFrameRef.contentWindow.document.body.innerHTML;:
Error message :VM1992:1 Uncaught DOMException: Blocked a frame with origin “http://localhost:8080” from accessing a cross-origin frame.
Out of commission JavaScript Visit... From different sources iframe, To avoid any possible safety risks . For homologous strategies , The browser will prevent the script from trying to access iframe.
actually , I can't be 8080 Port of index.html In context , View another iframe Any attribute of , Report the same mistake :
Then I'll be in advance iframe Detect on creation :

Just created iframe,href yes about:blank:

Until this function is executed ,this.oIFrameRef.contentWindow.location.href Are accessible :
beforeRendering In the hook of ,this.oIFrameRef.contentWindow.location.href Still available , however afterRendering Your hook won't work :

This before and afterRendering The hook , Click on Browse… Button to select a local file , It will be triggered once each .
After selection , Click on Upload Button , It will trigger again :
Click on upload File after , perform submit Before , All can be accessed normally :this.oIFrameRef.contentWindow.location.href
post To 3003 after , No more visits :
边栏推荐
- 【SAML SSO解决方案】上海道宁为您带来SAML for ASP.NET/SAML for ASP.NET Core下载、试用、教程
- Xcode 发布测试包TestFlight
- C语言之指针进阶
- 牛客题目——二叉搜索树与双向链表
- Niuke topic - parity rearrangement of linked list, right view of output binary tree, bracket generation, first non repeating character in character stream
- 2021-05-30
- C语言之文件操作
- Character stream read file
- Functions in JS
- C语言之函数
猜你喜欢

Character function, string function and memory function of C language

SAP UI5 FileUploader 的隐藏 iframe 设计明细

Built in object (bottom)

C语言之操作符

SAP UI5 FileUploader 使用的隐藏 iframe 和 form 元素的设计明细

Reference of meta data placeholder

Kubernetes第七篇:使用kubernetes部署prometheus+grafana监控系统(Kubernetes工作实践类)

如何通过C#/VB.NET从PDF中提取表格

内置对象(下)

牛客题目——对称的二叉树
随机推荐
合工大苍穹战队视觉组培训Day7——视觉,jetson naon与D435i
SAP UI5 FileUploader 的隐藏 iframe 设计明细
每条你收藏的资讯背后,都离不开TA
Leader: who uses redis overdue monitoring to close orders and get out of here!
Shardingsphere-proxy-5.0.0 distributed snowflake ID generation (III)
内置对象(下)
从零开始Blazor Server(1)--项目搭建
Jerry's book can't find Bluetooth solutions [article]
Niuke topic - the minimum number of K
2021-05-30
Servlet中文乱码setContentType设置无效
.NET Core with 微服务 - 什么是微服务
随机数公式Random
Dynamic memory allocation in C language
项目练习:表格的查改功能
File class byte input and output stream
Three table joint query 1
Cryptography series: certificate format representation of PKI X.509
Flex弹性盒布局
Xcode 发布测试包TestFlight