Yes, I read those articles before I posted links to them. I realized
that they were exactly what you needed... save the byte array of a
file directly to the database.

While I do not personally recommend this approach because you are
ignoring the primary paradigm of application security - "All input is
evil until proven otherwise !" Most developers like to run an
antivirus check at the very least on the file before saving it
anywhere. Secondly, I also do not recommend saving files into the DB.
(One of the articles I linked to also reiterates this point)

Nevertheless, it is what you wanted.

And you're welcome. :-)

On Feb 9, 4:10 am, Pete <[email protected]> wrote:
> Hi Cerebrus,
>
> Thanks for your help . . .
>
> Actually, I don't want to really save the file on the server and I was
> confused how to get the stream without doing this.  However, one of
> your links has enlightened me on how to do this.  The code below is
> what I need:
>
>         HttpPostedFile myFile = FileUpload1.PostedFile;
>         int nFileLen = myFile.ContentLength;
>         byte[] myData = new byte[nFileLen];
>         myFile.InputStream.Read(myData, 0, nFileLen);
>
> All I want to do is get the byte array of the file in question and
> then load it into the database.  The above code will get the byte
> array and I can do the rest.  I just wasn't aware of how to do this
> but now I know thanks to you. . .
>
> Thanks so much for your help,
>
> Pete
>
> On Feb 8, 1:10 am, Cerebrus <[email protected]> wrote:
>
>
>
> > I have a feeling that these articles might be helpful to you:
>
> >http://www.codeproject.com/KB/aspnet/fileupload.aspxhttp://www.aspcod...- 
> >Hide quoted text -
>
> - Show quoted text -

Reply via email to