濮阳杆衣贸易有限公司

主頁 > 知識庫 > 上傳圖片后使用數(shù)據(jù)庫保存圖片的示例分享

上傳圖片后使用數(shù)據(jù)庫保存圖片的示例分享

熱門標簽:云狐人工智能電話機器人 電銷機器人 數(shù)據(jù) 怎樣給陜西地圖標注顏色 400電話辦理信任翰諾科技 廣州銷售外呼系統(tǒng)定制 宿遷智能外呼系統(tǒng)排名 ai電銷機器人對貸款有幫助嗎 福州人工智能電銷機器人加盟 地圖標注多少錢一張

復制代碼 代碼如下:

HttpPostedFile UpFile = File1.PostedFile;
int FileLenght = UpFile.ContentLength;
decimal FileSize = FileLenght / 1024;
if (FileLenght == 0)
{
    DIVShowGVError.Visible = true;
    LblShowGVError.Text = "請選擇上傳文件";
    return;
}
string strImageName = UpFile.FileName;
string strImageType = strImageName.Substring(strImageName.LastIndexOf(".")).ToLower();
if (strImageType != ".jpg" strImageType != ".jpeg" strImageType != ".bmp" strImageType != ".png")
{
    DIVShowGVError.Visible = true;
    LblShowGVError.Text = "請上傳以下文件格式的圖片:jpg,jpeg,bmp,png";
    return;
}
if (FileSize > 2048)
{
    DIVShowGVError.Visible = true;
    LblShowGVError.Text = "上傳圖片不能大於2M";
    return;
}
else
{
    Byte[] FileByteArray = new Byte[FileLenght];
    Stream StreamObject = UpFile.InputStream;
    StreamObject.Read(FileByteArray, 0, FileLenght);

    strNewLeave = "insert into [Leave]([ID],[EmployeeNo],[AgentID],[LeaveType],[StartDate],[EndDate],[Hours],[LeaveReason],[ReportTime],[ReportID],[ImageName],[ImageData]) ";
    strNewLeave += "values(@LeaveNo,@EmpNo,@AgentName,@LeaType,@StartDate,@EndDate,@Hours,@Reason,getdate(),@Admin,@ImageName,@Image) ";

    sqlPara = new SqlParameter[] {
    new SqlParameter("@LeaveNo",strLeaNo),
    new SqlParameter("@EmpNo",strEmpNo),
    new SqlParameter("@AgentName",strAgentID),
    new SqlParameter("@LeaType",strLeaType),
    new SqlParameter("@StartDate",strDateSt),
    new SqlParameter("@EndDate",strDateEnd),
    new SqlParameter("@Hours",strHours),
    new SqlParameter("@Reason",strReason),
    new SqlParameter("@Admin",strAdmin),
    new SqlParameter("@ImageName",strImageName),
    new SqlParameter("@Image",FileByteArray)
    };

    StreamObject.Close();
}

復制代碼 代碼如下:

SQLHelper sqlH = new SQLHelper();
        string strID = context.Request["ID"];
        byte[] MyData = new byte[0];
        string str = "  select [ImageData] from [Leave] where [ID]='" + strID + "' ";
        DataTable dt = sqlH.ExecuteQuery(str, CommandType.Text);
        if (dt.Rows.Count > 0)
        {
MyData = (byte[])dt.Rows[0][0];
int ArraySize = MyData.GetUpperBound(0);

context.Response.OutputStream.Write(MyData, 0, ArraySize);
        }

您可能感興趣的文章:
  • js讀取被點擊次數(shù)的簡單實例(從數(shù)據(jù)庫中讀取)
  • sql server 2008數(shù)據(jù)庫連接字符串大全
  • openfiledialog讀取txt寫入數(shù)據(jù)庫示例
  • sql2000數(shù)據(jù)庫清除重復數(shù)據(jù)的二種方法
  • linux數(shù)據(jù)庫備份并通過ftp上傳腳本分享
  • java使用jdbc操作數(shù)據(jù)庫示例分享
  • MySQL數(shù)據(jù)庫命名規(guī)范及約定
  • net操作access數(shù)據(jù)庫示例分享
  • mysql跨數(shù)據(jù)庫復制表(在同一IP地址中)示例
  • Drupal7連接多個數(shù)據(jù)庫及常見問題解決
  • Drupal讀取Excel并導入數(shù)據(jù)庫實例
  • sqlserver備份還原數(shù)據(jù)庫功能封裝分享
  • Drupal7中常用的數(shù)據(jù)庫操作實例
  • android通過jxl讀excel存入sqlite3數(shù)據(jù)庫
  • java自定義動態(tài)鏈接數(shù)據(jù)庫示例
  • php把session寫入數(shù)據(jù)庫示例
  • 在linux中導入sql文件的方法分享(使用命令行轉(zhuǎn)移mysql數(shù)據(jù)庫)
  • 四種數(shù)據(jù)庫隨機獲取10條數(shù)據(jù)的方法

標簽:新疆 綿陽 延安 宜春 大興安嶺 黃南 焦作 曲靖

巨人網(wǎng)絡通訊聲明:本文標題《上傳圖片后使用數(shù)據(jù)庫保存圖片的示例分享》,本文關(guān)鍵詞  上傳,圖片,后,使用,數(shù)據(jù)庫,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《上傳圖片后使用數(shù)據(jù)庫保存圖片的示例分享》相關(guān)的同類信息!
  • 本頁收集關(guān)于上傳圖片后使用數(shù)據(jù)庫保存圖片的示例分享的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    普安县| 东乡族自治县| 临西县| 龙游县| 屯门区| 灌云县| 措勤县| 岑巩县| 济宁市| 福州市| 高雄市| 那曲县| 上高县| 天津市| 桑植县| 洪洞县| 丰城市| 金堂县| 托克托县| 白银市| 吉木萨尔县| 瑞昌市| 文登市| 兴业县| 安化县| 盐池县| 澜沧| 澎湖县| 毕节市| 郑州市| 德化县| 和平区| 湘阴县| 克山县| 鹤庆县| 巩义市| 易门县| 无锡市| 政和县| 始兴县| 阳山县|