[英]How to get FileName and upload file in asp.net JQuery without using File Upload
I am trying to upload image file(s) for my project with bootstrap jquery using the HTML5 input type="file" tag in ASP.NET 3.5 .我正在尝试使用ASP.NET 3.5 中的 HTML5 input type="file"标签通过 bootstrap jquery 为我的项目上传图像文件。 I tried so many different methods to do it without using File Upload.我尝试了很多不同的方法来做到这一点,而不使用文件上传。 However, I couldn't do it with success.但是,我无法成功。
I need your help please.我需要你的帮助。 How can I use "input type="file" … " instead of asp:FileUpload如何使用“输入类型=“文件”...“而不是asp:FileUpload
Thanks in advance.提前致谢。
.aspx design page is like this: .aspx设计页面是这样的:
<div class="row">
<div class="col-xs-12 col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
<!-- image-preview-filename input [CUT FROM HERE]-->
<div class="input-group image-preview">
<input type="text" class="form-control image-preview-filename" disabled="disabled" />
<!-- don't give a name === doesn't send on POST/GET -->
<span class="input-group-btn">
<!-- image-preview-clear button -->
<button type="button" class="btn btn-default image-preview-clear" style="display:none;">
<span class="glyphicon glyphicon-remove"></span> Temizle
</button>
<div class="btn btn-default image-preview-input">
<span class="glyphicon glyphicon-folder-open"></span><span class="image-preview-input-title">
Choose File</span>
<input type="file" accept="image/png, image/jpeg, image/gif" name="input-file-preview" />
<!-- rename it -->
</div>
</span>
</div>
<!-- /input-group image-preview [TO HERE]-->
</div>
/div>
<div class="w3-container w3-padding">
<table width="100%">
<tr>
<td width="16%">
<td width="25%">
<asp:LinkButton ID="resimYukle" runat="server" class="w3-btn w3-theme"
onclick="resimYukle_Click">
<span aria-hidden="true" class="fa fa-pencil"></span> Save</asp:LinkButton>
<td width="59%">
</td>
</td></td></tr></table>
</div>
Screenshot is like this:截图是这样的:
There are two ways to get file name in server side you can use asp controls or you can use bootstrap controls and use runat="server"
eg有两种方法可以在服务器端获取文件名,您可以使用 asp 控件,也可以使用引导程序控件并使用runat="server"
例如
<input type="file" id="filebtn" accept="image/png, image/jpeg, image/gif" runat="server" name="input-file-preview" />
and in cs file use properties as并在 cs 文件中使用属性作为
var name= filebtn.PostedFile.FileName;
or InputStream
or SaveAs
或InputStream
或SaveAs
and in asp you can use asp controls but apply css class在 asp 中你可以使用 asp 控件但应用 css 类
<asp:FileUpload ID="fileupload" CssClass="applyclass" runat="server" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.