materix
Posts: 161
|
Posted: 04/25/2009, 1:35 PM |
|
Hi Waspman.
YES is partly right, as javascript alone can not access files from the user's directory (image the security risk that would be). But it is though possible to achieve the effect you are asking, by posting the form to a hidden iframe which then uploads the file.
Add a client side event "On Submit" to the FORM that contains the FileUpload control, and insert the following javascript code:
var hiddeniframe, name;
name = this.getAttribute("name")+'_iframe';
hiddeniframe = document.createElement("iframe");
hiddeniframe.setAttribute("id", name);
hiddeniframe.setAttribute("name", name);
hiddeniframe.setAttribute("width","0");
hiddeniframe.setAttribute("height","0");
hiddeniframe.setAttribute("border","0");
hiddeniframe.setAttribute("style","width: 0; height: 0; border: none;");
this.parentNode.appendChild(hiddeniframe);
window.frames[name].name = name;
this.setAttribute("target",name);
this.submit();
Hope that helps.
|