当前位置:网站首页>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 :
边栏推荐
- Mobile end Foundation
- Select structure
- mysql视图及存储过程
- Global string object (function type) +math object
- Niuke topic - parity rearrangement of linked list, right view of output binary tree, bracket generation, first non repeating character in character stream
- Flex弹性盒布局
- Passive income: return to the original and safe two ways to earn
- Basic use and optimization of uitableview
- How does vs2019 C language run multiple projects at the same time, how to add multiple source files containing main functions in a project and debug and run them respectively
- 两表联查1
猜你喜欢

Layoff quarrel, musk: I'm too hard; Mercilessly open source a public opinion acquisition project; Feature engineering is as simple as parameter adjustment?! Nerf boss shouted that he couldn't move; Cu

Getting started with nvida CUDA dirverapi

JDBC connection database

Select structure

JSP El expression, JSTL tag

mysql视图及存储过程

WebView basic use

Three table joint query 1

内置对象(下)

Character stream read file
随机推荐
Shardingsphere-proxy-5.0.0 distributed snowflake ID generation (III)
Complete steps of JDBC program implementation
动作捕捉系统用于柔性机械臂的末端定位控制
Gartner authority predicts eight development trends of network security in the next four years
SAP UI5 FileUploader 的本地文件上传技术实现分享
通过 FileUploader 的初始化,了解 SAP UI5 应用的 StaticArea 初始化逻辑
Cryptography series: certificate format representation of PKI X.509
Jerry's book can't find Bluetooth solutions [article]
Character function, string function and memory function of C language
数据采集之:巧用布隆过滤器提取数据摘要
C语言之字符函数和字符串函数及内存函数
Niuke topic -- Realizing queues with two stacks, stacks containing min functions, and valid bracket sequences
第7天总结&作业
C语言之指针进阶
File operation in C language
File class byte input and output stream
Understand the basic properties of BOM and DOM
随机数公式Random
牛客题目——链表的奇偶重排、输出二叉树的右视图、括号生成、字符流中第一个不重复的字符
合工大苍穹战队视觉组培训Day8——视觉,目标识别