Iframe non-refresh file upload is actually to open the upload program page on the current page, which is a bit like ajax partial refresh, except that we put it into the iframe page for upload, and at the same time we hide the iframe page.
The most original and simple iframe upload example:
In this example, the iframe name is used, so when the form is submitted, the link will be opened in the iframe (that is, there is no refresh, to be precise, it should be
It feels like there is no refresh)
When the form is submitted, the startUpload method is called, which of course is defined by JS.
The front-end upload page index.html is mainly a form and a js callback function. When uploading files, the method and enctype attributes of the form must be the same as the following code. Then set the target value to the name of the iframe, so that files can be uploaded without refreshing.
The code is as follows | Copy code | ||||
|
}
代码如下 | 复制代码 |
if($result) |
The code is as follows | Copy code |
The code is as follows | Copy code |
if($result) { echo "Upload successful! The file path is: ".$file2; echo ''; echo'<script>parent.document.form1.img.value=document.getElementById("img").value;</script>'; } |
After the file is uploaded successfully, write the file path into a hidden field (img), and then use the DOM principle to send the VALUE in the hidden field to the img text box of form1 in the parent frame:
OK, let’s take a look at Tamsui.
Tamsui editor uses tinyMCE, so it is a little different.
My form page:
The code is as follows
|
Copy code
|
||||||||
Previous article:PHP uses curl_init to initiate http requests to simulate login_PHP tutorial
Next article:PHP generates random string program code_PHP tutorial
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
Embedding HTML generated by an R function
I want to dynamically build html and render that html in quarto. The actual application in...
From 2024-04-01 20:51:51
0
1
367
Embed/iframe always full height
I have embedded several html files that vary in "height". I want the embedded co...
From 2024-03-31 09:50:18
0
1
400
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
|