To preview a local image, you can obtain the image path from the file value in IE6 to display the preview. In IE7 and IE8, you can obtain the image path of the file through select, use a filter to display the preview. For FireFox, read this article and hope to help you with your local image preview requirements during Web project development, although I was not able to use it for other reasons, I had some knowledge about it and sorted it out.
Here we divide by browser, mainly including IE6, IE7/8, and Firefox3, excluding Opera, Safari, and Chrome. These three are basically very small and have not been studied.
To sum up:
In IE6, you can directly obtain the image path from the file value to display the preview.
In IE7 and IE8, you can use select to obtain the file image path, and then use a filter to display the preview.
In FireFox, The getAsDataURL method of file is called to obtain Data URI Data to display the preview.
The following is a complete Demo:
The Code is as follows: