0
<asp:FileUpload ID="FileUploadPassfoto" runat="server" 
                Width="100%" Style="background-color: #533473; border-color: lightgray;" />

This is my FileUpload created with asp.net. Only images will be uploaded! In my C# Code Behind i tried this code:

HttpPostedFile file = FileUploadPassfoto.PostedFile;
using (BinaryReader binaryReader = new BinaryReader(file.InputStream))
{
    lehrling.passfoto = Convert.ToBase64String(binaryReader.ReadBytes(file.ContentLength));
}

lehrling.passfoto is a string variable. When i debug through my code. the lehrling.passfoto has the value "". So an empty string. What am i doing wrong? The httppostedfile works just fine. The filepath and contentlenght are correct.... Any suggestions

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • Have you verified that `binaryReader.ReadBytes(file.ContentLength)` is returning any data? – Der Kommissar Sep 27 '16 at 08:04
  • its not a duplicate. i didnt ask for a path... read my question properly. I dont NEED A PATH!!!!!! @aristos –  Sep 27 '16 at 09:00

0 Answers0