jquery - Read filename to the textbox from fileupload window -
in asp.net application, have used textbox
, button
, hidden fileupload control
.
when button clicked using jquery getting fileupload window
below,
protected void btn_browse_click(object sender, eventargs e) { stringbuilder strscript = new stringbuilder(); strscript.append("$(document).ready(function(){"); strscript.append("$('#fileupload1').click();"); strscript.append("});"); page.clientscript.registerstartupscript(this.gettype(), "script", strscript.tostring(), true); txt_filename.text=fileupload1.filename; }
my issue unable show selected filename fileupload
textbox
.
filename not displaying in textbox
any suggessions.
on serverside can this:
string filename = path.getfilename(fid.postedfile.filename); fid.saveas(server.mappath("files/"+filename)); string fpath = "files/"+filename;
and jquery:
$(document).ready(function () { $("#btnfileupload").click(function () { var fupload = $("#fileuploadcontrol").val(); } }
for javascript:
<script type="text/javascript"> function getfilename() { var varfile = document.getelementbyid("fileuploadcontrol"); document.getelementbyid("filename").value = varfile.value; } </script>
fileupload control :
<asp:fileupload id="fileuploadcontrol" runat="server" onchange="getfilename()"
Comments
Post a Comment