i have written some code to upload a file in byte[] array i am getting all the values as zero. at the end of the beloww given code.
is the due to timing since once i gave a sleeep in between the codes the byte array is working correctly.I have attached the code.
imageContent is the byte[] array and after executing the last statement the value is filled with zeros.
//////////
Int32 imageSize;
string imageType;
string imgname;
Stream imageStream;

imageSize = FileUpload1.PostedFile.ContentLength;

imageStream = FileUpload1.PostedFile.InputStream;

imgname = FileUpload1.PostedFile.FileName;

byte[] imageContent = new byte[imageSize];


int intStatus;
intStatus = imageStream.Read(imageContent, 0, imageSize);

///////////////////////////////////////

Punnoose.P.J

try to save image location to database instead to store image bit information, it will be easier

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.