I would like to show preview image without the image is being uploaded. Preferably if I can crop the image first, then show preview. What is the best way to do this? I heard this can be done with jquery and ajax. My website is using cakePHP.
Asked
Active
Viewed 238 times
1 Answers
0
The html code:
<input type="file" id="files" />
<img id="image" />
The JavaScript code:
document.getElementById("files").onchange = function () {
var reader = new FileReader();
reader.onload = function (e) {
// get loaded data and render thumbnail.
document.getElementById("image").src = e.target.result;
};
// read the image file as a data URL.
reader.readAsDataURL(this.files[0]);
};
You may refer More Here

Adharsh M
- 2,773
- 2
- 20
- 33