Cross-origin problem of using IFRAME to upload a file to obtain the returned value

Source: Internet
Author: User
Because a general upload is required,
Therefore, you can directly upload a previously written file. Program Copy it,
I want to pass two parameters: input name and form name, and then the value will be automatically returned,
You can call this method directly in other projects,
After the results are written, the local test is normal, Code As follows:

< Form Name = "Myform" Action = "Myjsp" >
< Input Type = Text Name = "Pic" >
< IFRAME SRC = "Upload? Form = myform & inputname = pic" > </ IFRAME >
</ Form >

After processing the complete upload process, use

< Script > Parent.doc ument. form name. Input name. Value = 'Path Path' </ Script >

To automatically return the upload path to the input box,
Of course, there is nothing wrong with writing this way, and I have always used it like this,
But this time something went wrong,
I am normal on the local machine, and the value can be returned correctly,
However, when my colleagues use it on another computer, the problem arises,
Because the project is different, IFRAME must be included in the complete path,
That is to say,

< IFRAME SRC = "Http:// Form = myform & inputname = pic" > </ IFRAME >

Ho, the problem arises. An error is prompted after the upload and access is denied,
Dizzy, how can I deny access? Hurry up, GG,
Cross-origin access is detected. Cross-origin access is disabled by IE by default,
It seems like this. The value cannot be returned. How can this problem be solved,
Find another method,
This is pretty cool, and you don't need any form names or the like. :)

The complete code after modification is as follows:

< Form Name = "Myform" Action = "Myjsp" >
< Input Type = Text ID = Text1 >
< IFRAME SRC = "Http://" ID = T1 > </ IFRAME >
< Script For = T1 Event = Onload >
Text1.value = Window. status;
</ Script >
</ Form >


After the upload process is complete,

< Script > Window. Status = " Path: The uploaded path " ; </ Script >

This is more convenient than the initial method. :)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.