// Obtain the size of the uploaded file
Int filelen = fileimg. postedfile. contentlength;
Byte [] filedata = new byte [filelen];
// Create an object for accessing the client to upload files
Httppostedfile HP = fileimg. postedfile;
// Create a data stream object
Stream sr = hp. inputstream;
// Put the image data in the filedata array object instance. 0 indicates the starting position of the array pointer, and filelen indicates the Ending position of the pointer.
Sr. Read (filedata, 0, filelen );
# Endregion
String SQL = "insert into ptif (ptif_id, ptif_name, ptif_file, ptif_url, ptif_cont) values (Zhibao. Values,: ptif_name,: ptif_file,: ptif_url,: ptif_cont )";
Try
{
String fileurl = fileclass. getfileurlname ();
Oracleparameter [] parms =
{
// Ptif_id, ptif_name, ptif_file, ptif_url, ptif_cont
// Oraclehelper. makeinparam (": ptif_id", oracletype. Char, admin_id ),
Oraclehelper. makeinparam (": ptif_name", oracletype. Char, name. Text ),
Oraclehelper. makeinparam (": ptif_file", oracletype. Blob, filedata ),
Oraclehelper. makeinparam (": ptif_url", oracletype. Char, fileurl ),
Oraclehelper. makeinparam (": ptif_cont", oracletype. Char, textbox1.text)
};
Oraclehelper. executenonquery (oraclehelper. connectionstringlocaltransaction, commandtype. Text, SQL, parms );
If (chkaddcontinue. Checked)
{
Response. Write ("<script language = 'javascript '> alert (' added successfully! '); Window. Location. href = 'addpicture. aspx'; </SCRIPT> ");
}
Else
{
Response. Write ("<script language = 'javascript '> alert (' added successfully! '); Window. Location. href = 'picturelib. aspx'; </SCRIPT> ");
}
}
Catch
{
Response. Write ("error ");
}