だから私はこのコードを持っています:
if ((uplImage.FileName != ""))
{
byte[] raw = new byte[10000];
//to allow only jpg gif and png files to be uploaded.
string extension = Path.GetExtension(uplImage.PostedFile.FileName.ToUpper());
if (((extension == ".JPG") || ((extension == ".GIF") || (extension == ".PNG"))))
{
DALBio bio = new DALBio();
FileStream fs = new FileStream(uplImage.PostedFile.FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
fs.Read(raw, 0, System.Convert.ToInt32(fs.Length));
bio.PlayerID = Session["playerID"].ToString();
bio.Pending = 'Y';
bio.Photo = raw;
DALBio.insertImage(bio);
}
}
これを試してみると、ストリームが画像を読み取っていません。raw
イメージは決して得られません。空のままで、ストアドプロシージャを実行すると、イメージを渡したことがないと言ってキャッチされます。コードは問題ないと確信しています。画像をバイト配列に取り込めない理由がわかりません。