function onSubmitPicture() {
document.getElementById('FileUploadF').click(); // here File Upload Dialog open
}
function onUploadPicture() {
if (CheckRequired(document.getElementById('FileUploadF'), 'Please browse file to upload') == false) {
return false;
}
imagefile_value = document.getElementById('FileUploadF').value;
var checkimg = imagefile_value.toLowerCase();
if (!checkimg.match(/(\.jpg|\.gif|\.png|\.JPG|\.GIF|\.PNG|\.jpeg|\.JPEG)$/)) {
ShowMessage('Please upload valid Image file.');
return false;
}
else { document.getElementById('btnSavePicture').click(); // here it is not working in IE 9 get Access denied and FF and Chrome are giving click event fired.
}
}
bhargav5126
Member
153 Points
71 Posts
MVC File Upload using button click in Jquery
Aug 24, 2012 07:04 AM|LINK
document.getElementById('FileUploadF').click();
or
$('#FileUploadF').click();
not working in IE 9.
Here is HTML code
<a id="aChangePicture" onclick="return onSubmitPicture();" style="cursor: pointer">
Change Profile Picture</a>
<input name="FileUploadF" id="FileUploadF" type="file" onchange="onUploadPicture();"
style="display: none" />
<input type="submit" value="Picture" id="btnSavePicture" name="save" class="bbutton"
style="display: none" />
And
script is
function onSubmitPicture() {
document.getElementById('FileUploadF').click(); // here File Upload Dialog open
}
function onUploadPicture() {
if (CheckRequired(document.getElementById('FileUploadF'), 'Please browse file to upload') == false) {
return false;
}
imagefile_value = document.getElementById('FileUploadF').value;
var checkimg = imagefile_value.toLowerCase();
if (!checkimg.match(/(\.jpg|\.gif|\.png|\.JPG|\.GIF|\.PNG|\.jpeg|\.JPEG)$/)) {
ShowMessage('Please upload valid Image file.');
return false;
}
else {
document.getElementById('btnSavePicture').click(); // here it is not working in IE 9 get Access denied and FF and Chrome are giving click event fired.
}
}
Give me proper solution.
S4NDERR
Member
169 Points
41 Posts
Re: MVC File Upload using button click in Jquery
Aug 24, 2012 08:41 AM|LINK
It is secured not work.
You will have to use a Jquery plugin for this but no worries, there are 1000s.
dKHdMvc
Member
12 Points
7 Posts
Re: MVC File Upload using button click in Jquery
Nov 04, 2012 04:32 AM|LINK
You should be using out of box file uploader to do this kind of activity. It need many times to finish it. Here are some examples:
http://blog.stevensanderson.com/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/
http://ajaxuploader.com/using-uploader-in-mvc.htm