Most of the time we will be on some websites, such as writing online resumes, we will find our pictures selected, will immediately appear on the current page. We often think that this kind of things only Ajax can be achieved, today I learned a little bit, found that this thing is not AJAX implementation.
Finally, we use the form in our basic knowledge HTML to implement the upload. OK, now I will know what I have written, as a study, of course, this is only my own study notes, if the wrong place, I hope the same people give guidance twos.
First we make it clear that uploading images, we still use this situation.
But how can you make the uploaded image appear without refreshing it? Here we need to do an understanding.
Friends who have used this tag know that it can divide your page into sections, and each section can have its own URL, which shows several different pages. Maybe some friends already know what's going on here. Yes, uploading images is the use of this principle. It looks like it's on the same page, no jumps, and then it actually jumps, just what we didn't see. OK, here is a simple example that I hope will help you. (php+html)
The first is the index.php page, the code is simple as follows:
| The code is as follows |
Copy Code |
|
Then the hello.php page, which is the image upload page
| The code is as follows |
Copy Code |
echo $_files["TValue" ["Tmp_name"]; if (Move_uploaded_file ($_files["TValue" ["Tmp_name"], "img/a.jpg")) { echo ""; } ?> |
As you can say, these lines of code will be able to implement the effects we need.
Here's an analysis:
First, there is a target in the form, and its value is an IFRAME in it. Meaning, after we commit, the page will show up in this IFRAME,
From the definition of IFRAME, its content is hello.php. So our form is submitted directly to the IFRAME inside, so the page will not jump, but we have completed the
Mass transfer In the hello.php view, after uploading it will choose to display the picture, from the front can know hello.php content will be displayed in the IFRAME, so finally we see the effect is the page does not jump, we can make a similar AJAX implementation of the effect, upload the image can be displayed in the current.
http://www.bkjia.com/PHPjc/633166.html www.bkjia.com true http://www.bkjia.com/PHPjc/633166.html techarticle Most of the time we will be on some websites, such as writing online resumes, we will find our pictures selected, will immediately appear on the current page. We often think that this kind of thing only ...