当前位置:网站首页>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 :
边栏推荐
- C语言之字符函数和字符串函数及内存函数
- Jerry's in ear detection function [chapter]
- Cryptography series: certificate format representation of PKI X.509
- Character function, string function and memory function of C language
- Flex flex flex box layout
- 全局String对象(函数类型)+Math对象
- Measured: the performance of cloud RDS MySQL is 1.6 times that of self built
- MySQL: 函数
- C语言之数据的储存
- URL return nil and urlhash processing
猜你喜欢

.net core with microservices - what is a microservice

js中的函数

Node package depends on download management

Pointer elementary of C language

Shell programming specifications and variables

File class byte input and output stream

Structure and bit segment of C language

JSP El expression, JSTL tag

Xcode releases test package testflight

Enumeration and union of C language
随机推荐
MPC5744p时钟模块
Two table joint query 1
Jerry's built-in touch parameters for modification [chapter]
通过 FileUploader 的初始化,了解 SAP UI5 应用的 StaticArea 初始化逻辑
被动收入:回归原始且安全的两种赚取方法
三表联查1
[SAML SSO solution] Shanghai daoning brings you SAML for asp NET/SAML for ASP. Net core download, trial, tutorial
Kubernetes第七篇:使用kubernetes部署prometheus+grafana监控系统(Kubernetes工作实践类)
三表联查3
ES6数组新增属性
Flex弹性盒布局
ES6数组的方法及伪数组转数组方法
全局String对象(函数类型)+Math对象
Basic use and optimization of uitableview
Unity 入门
第7天总结&作业
Character function, string function and memory function of C language
Niuke topic - parity rearrangement of linked list, right view of output binary tree, bracket generation, first non repeating character in character stream
Matplotlib drawing error: "! Latex error: file `type1cm.sty 'not found." solution
day07 作业