亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長(zhǎng)資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    ASP上傳圖片到數(shù)據(jù)庫(kù)的代碼


    ASP將圖片上傳到數(shù)據(jù)庫(kù)的代碼
    <%
    formsize=request.totalbytes
    formdata=request.binaryread(formsize)
    bncrlf=chrB(13)&chrB(10)
    divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)
    datastart=instrb(formdata,bncrlf&bncrlf)+4
    dataend=instrb(datastart+1,formdata,divider)-datastart
    mydata=midb(formdata,datastart,dataend)
    sql=”select * from pic”
    getdata(sql)
    rs.addnew
    rs(“img”).AppendChunk myData
    rs.update
    rsclose()
    response.clear
    response.write “success!”
    end if
    %>  <%

    ‘這是一段將圖片上傳到數(shù)據(jù)庫(kù)的代碼

     

    formsize=request.totalbytes
    ‘獲取請(qǐng)求中包括的總字節(jié)數(shù)

     

    formdata=request.binaryread(formsize)
    ‘保存從客戶端讀取到的二進(jìn)制數(shù)據(jù)

     

    bncrlf=chrB(13)&chrB(10)
    divider=leftB(formdata,clng(instrb(formdata,bncrlf))-1)
    ‘分隔標(biāo)志串
    ‘數(shù)據(jù)長(zhǎng)度,減1是因?yàn)閿?shù)據(jù)文件的存取字節(jié)數(shù)問題(可能是AppendChunk方法的問題):
    ‘由于字節(jié)數(shù)為奇數(shù)的圖象存到數(shù)據(jù)庫(kù)時(shí)會(huì)去掉最后一個(gè)字符導(dǎo)致圖象不能正確顯示,
    ‘字節(jié)數(shù)為偶數(shù)的數(shù)據(jù)文件就不會(huì)出現(xiàn)這個(gè)問題,因此必須保持字節(jié)數(shù)為偶數(shù)。

     

    datastart=instrb(formdata,bncrlf&bncrlf)+4
    ‘分隔標(biāo)志串長(zhǎng)度

     

    dataend=instrb(datastart+1,formdata,divider)-datastart
    ‘減去分隔標(biāo)志串長(zhǎng)度

     

    mydata=midb(formdata,datastart,dataend)
    ‘獲取最終數(shù)據(jù)

     

    sql=”select * from pic”
    getdata(sql)
    ‘getdata為自定義函數(shù),連接、打開數(shù)據(jù)庫(kù)、并運(yùn)行sql語句

    rs.addnew
    ‘添加新的數(shù)據(jù)

     

    rs(“img”).AppendChunk myData
    ‘使用AppendChunk方法添加數(shù)據(jù)

     

    rs.update
    ‘更新數(shù)據(jù)庫(kù)

     

    rs.close()
    ‘關(guān)閉數(shù)據(jù)庫(kù)

     

    response.clear
    ‘清除緩沖區(qū)中的所有 HTML 輸出

     

    response.write “success!”
    ‘顯示成功信息

     

    end if
    ‘最前面應(yīng)該有if…then語句
    %>

     

    分享到: 更多

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)