I have a requirement, like, I need to upload a XML file, from local system, into a HTML webresource of CRM 2011 application. I am using the below code, which I got from various blogs. But I am getting "Permission Denied" error on the line "
xmlhttp.open("GET", dname, false); ". I am using IE to perform this action.
The below code is perfectly working fine, when I try to upload file, having both html page and xml file in my local system.
Please help me on how to resolve this issue.
function fileupload(){
var str = document.getElementById('File1').value;// getting the path of the xml file from html page.
var oXmlDoc = loadXMLDoc(str);
}
function loadXMLDoc(dname) {
var xmlhttp=false;
/* running locally on IE5.5, IE6, IE7 */
if(location.protocol=="file:"){
if(!xmlhttp)try{ xmlhttp=new ActiveXObject("MSXML2.XMLHTTP"); }catch(e){xmlhttp=false;}
if (!xmlhttp) try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlhttp = false; }
}
/* IE7, Firefox, Safari, Opera... */
if (!xmlhttp) { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp = false; } }
/* IE6 */
if(typeof ActiveXObject != "undefined"){
if(!xmlhttp)try{ xmlhttp=new ActiveXObject("MSXML2.XMLHTTP"); }catch(e){xmlhttp=false;}
if(!xmlhttp)try{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){xmlhttp=false;}
}
/* IceBrowser */
if(!xmlhttp)try{ xmlhttp=createRequest(); }catch(e){xmlhttp=false;}
if (!xmlhttp) return alert("Your browser doesn't seem to support XMLHttpRequests.");
xmlhttp.open("GET", dname, false);
xmlhttp.send(null);
if (!xmlhttp.status || xmlhttp.status == 200) {
alert(xmlhttp.responseText);
return xmlhttp.responseXML;
}
else {
alert("Request failed!");
}
}