fileUpload.PostedFiles[]
プロパティを使用できませんか?
私は実際に複数のファイルアップローダーとサイズ変更が必要です。
私HttpFileCollection
はすべてのファイルにhfcを使用しています。それは常に間違っていstring filename = fileUpload
ます。
これはこれを行うための良い方法ですか?
protected void UploadFile_Click(object sender, EventArgs e)
{
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
if (hpf.ContentLength > 0)
{
if (fileUpload.HasFile)
{
**string filename=fileUpload.PostedFiles[i].FileName;**
string directory = Server.MapPath(@"Uploaded-Files\");
Bitmap originalBMP = new Bitmap(fileUpload.FileContent);
Bitmap newBMP = new Bitmap(originalBMP, 800, 480);
Graphics oGraphics = Graphics.FromImage(newBMP);
oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);
newBMP.Save(directory + "tn_" + filename);
originalBMP.Dispose();
newBMP.Dispose();
oGraphics.Dispose();
}
}
}
}