Previewing image uploads in MVC
In this example, let's create an MVC application that can preview images using a client script prior to uploading it on the server. Note that this recipe only covers the client script, and the server code for the upload is not dealt with. The following table shows a quick summary of the constructs used in this example:
Construct |
Type |
Description |
---|---|---|
|
jQuery selector |
This selects an element based on its ID. |
|
jQuery method |
This returns a string with the required attribute value of a matched element. It can also be used to set the attribute to the required value. |
|
jQuery event |
This is fired when the value of an element changes. It corresponds to the JavaScript |
|
Event handler provided by the FileReader interface |
This defines the event handler for the |
|
Method... |