1
Answer

How to display images from server folder using javascrip

Photo of Venkatesh K H

Venkatesh K H

7y
312
1
I have uploaded the files in the server folder with the name upload. The images are uploading into the that folder but now how to get all those images from upload folder and display all the images using javascript or ajax. please help. I have tried this code but didn't work. 
 
<script type="text/javascript">
function uploadStarted() {
$get("imgDisplay").style.display = "none";
}
function uploadComplete(sender, args) {
var imgDisplay = $get("imgDisplay");
imgDisplay.src = "upload";
imgDisplay.style.cssText = "";
var img = new Image();
img.onload = function () {
imgDisplay.style.cssText = "height:100px;width:100px";
imgDisplay.src = img.src;
};
img.src = "upload" + args.get_fileName();
}
</script>
 

Answers (1)

0
Photo of Ashish Vishwakarma
NA 1.9k 45.5k 7y
Ok, you are using java, those steps belongs to IIS server.
You can simply make a GET Ajax request to server, if it is in same server
 If it is in different server, you need to enable CORS in server to acces files using AJAX