I have a Fileupload that I select several files and I save it in the directory, but I noticed that FileBytes of it, it also repeats in all the files.
if (FileUp.HasFiles)
{
foreach (HttpPostedFile uploadedFile in FileUp.PostedFiles)
{
Arquivo arq = new Arquivo();
ArquivoVersao arqVersao = new ArquivoVersao();
//seta as propriedades de arquivo
arq.XARQUIVO = Path.GetFileName(uploadedFile.FileName);
arq.EXTENSAO = Path.GetExtension(uploadedFile.FileName);
arq.ARQUIVOBYTE = FileUp.FileBytes;
FileUp.SaveAs(Server.MapPath("~/db_arquivos/") + arq.XARQUIVO);
}
}
aspx:
<div class="modal fade open" id="myModal" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" >
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">
<asp:Label ID="lblModalTitle" runat="server" Text="Enviar arquivos"></asp:Label></h4>
</div>
<div class="modal-body">
<asp:FileUpload ID="FileUp" AllowMultiple="true" runat="server" />
<br />
<input type="text" class="form-control" id="tokenfield" value="red,green,blue" />
</div>
<div class="modal-footer">
<asp:Button runat="server" CssClass="btn ui-icon-cancel small" ID="UpluodButton" OnClick="UploadButton_Click" Text="Enviar" />
</div>
</div>
</div>
</div>
My fileUpload is fired here:
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true);
The name, extension, etc. always comes right, but FileBytes always gets the size of the first file, summarizing the file is saved equally.