image preview and save to a folder
-
we want to upload a image file and preview to page and save to folder using javascript and c# code
-
we want to upload a image file and preview to page and save to folder using javascript and c# code
-
we want to upload a image file and preview to page and save to folder using javascript and c# code
If you're talking about ajax functionality for uploading, then please read this post of mine. Uploading the files – HTML5 and jQuery way![^]
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
-
If you're talking about ajax functionality for uploading, then please read this post of mine. Uploading the files – HTML5 and jQuery way![^]
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
Here:
<html>
<body>
<input id='input' type='file' onchange='newImage()'/>
Preview:
<button onclick='downloadImage()'>Download</button>
<script>
var input=document.getElementById('input'); //the <input> element
var image=document.getElementById('img'); //the elementfunction newImage(){
if(!input.files||input.value=='') return; //if there is no file then exit function
var file=input.files[0]; //get the file
if(!file.type.match('image.*')){ //if file is not an image
input.value=''; //clear input
alert('Images only!');
return; //exit function
}
var reader=new FileReader(); //now we read the image
reader.readAsDataURL(file); //convert image into a string
reader.onload=function(f){ //once the image string is received...
image.src=f.target.result; //send the image string to the image element
}
}function downloadImage(){
if(!image.src){
alert('There is nothing to download!');
return; //exit function if there is no image
}
var a=document.createElement('a');
a.setAttribute('href',image.src);
a.setAttribute('download','image.png');
a.click();
}
</script>
</body>
</html>Your welcome :-\
-
Here:
<html>
<body>
<input id='input' type='file' onchange='newImage()'/>
Preview:
<button onclick='downloadImage()'>Download</button>
<script>
var input=document.getElementById('input'); //the <input> element
var image=document.getElementById('img'); //the elementfunction newImage(){
if(!input.files||input.value=='') return; //if there is no file then exit function
var file=input.files[0]; //get the file
if(!file.type.match('image.*')){ //if file is not an image
input.value=''; //clear input
alert('Images only!');
return; //exit function
}
var reader=new FileReader(); //now we read the image
reader.readAsDataURL(file); //convert image into a string
reader.onload=function(f){ //once the image string is received...
image.src=f.target.result; //send the image string to the image element
}
}function downloadImage(){
if(!image.src){
alert('There is nothing to download!');
return; //exit function if there is no image
}
var a=document.createElement('a');
a.setAttribute('href',image.src);
a.setAttribute('download','image.png');
a.click();
}
</script>
</body>
</html>Your welcome :-\
I believe you wanted to send this message to OP. Didn't you?
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
-
I believe you wanted to send this message to OP. Didn't you?
The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
-
we want to upload a image file and preview to page and save to folder using javascript and c# code
Here:
<html>
<body>
<input id='input' type='file' onchange='newImage()'/>
Preview:
<button onclick='downloadImage()'>Download</button>
<script>
var input=document.getElementById('input'); //the <input> element
var image=document.getElementById('img'); //the elementfunction newImage(){
if(!input.files||input.value=='') return; //if there is no file then exit function
var file=input.files[0]; //get the file
if(!file.type.match('image.*')){ //if file is not an image
input.value=''; //clear input
alert('Images only!');
return; //exit function
}
var reader=new FileReader(); //now we read the image
reader.readAsDataURL(file); //convert image into a string
reader.onload=function(f){ //once the image string is received...
image.src=f.target.result; //send the image string to the image element
}
}function downloadImage(){
if(!image.src){
alert('There is nothing to download!');
return; //exit function if there is no image
}
var a=document.createElement('a');
a.setAttribute('href',image.src);
a.setAttribute('download','image.png');
a.click();
}
</script>
</body>
</html>Your welcome :-\