First, add
// <Input style = "width: 272px; height: 22px "type =" file "size =" 26 "name =" picfile "id =" picfile "runat =" server ">
CodeAs follows:
// Protected system. Web. UI. htmlcontrols. htmlinputfile picfile;
// Check and upload
private bool checkpic ()
{< br> bool issafe = false;
httppostedfile PIC = picfile. postedfile;
// check the extension
string picext = system. io. path. getextension (picfile. postedfile. filename ). tolower ();
If (picext = ". jpg "| picext = ". GIF "| picext =" BMP "| picext =" PNG ")
{< br> issafe = true;
}< br> else
{< br> issafe = false;
kit. alert (this. page, "the image format is incorrect. Convert the image format to JPG, GIF, BMP, and PNG.");
return issafe;
}< br> // check the image size
If (PIC. contentlength> picmaxlength ()
{< br> issafe = false;
kit. alert (this. page, "exceeds the image size limit");
return issafe;
}< br> // image size check
system. io. stream picstream = pic. inputstream;
system. drawing. image IMG = system. drawing. image. fromstream (picstream);
If (IMG. width> 0 & IMG. height> 0)
{< br> issafe = true;
// Step 3: Verify the ID card image and upload the
saveidcard (txtidcard. text. trim ();
Picstream. Close ();
Picstream. Flush ();
}
Else
{
Issafe = false;
Kit. Alert (this. Page, "invalid image file ");
// Picstream. Close ();
// Picstream. Flush ();
Return issafe;
}
Return issafe;
}