close
Imports System.IO
Imports System.Drawing

Imports SilverlightApplication1.Web.ClassStream.ClassStream

Public Class fileupload
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Using sr = New StreamReader(Request.InputStream)

'--------寫出檔案------------------
'法1:
'Dim data = sr.ReadToEnd()
'Dim byteArrayD = Convert.FromBase64String(data)

'Dim byteArray_stream = New MemoryStream(byteArrayD) '把收到的bytes 轉為stream
'Dim pp As New Bitmap(byteArray_stream)
'pp.Save("c:/cc/Temppic_D.jpg") '檔名是已知的jpg 所以才能這樣定

'---------------------
'法2:
Dim streamLength = sr.BaseStream.Length
Dim byteArrayF = ConvertStreamToBytes(sr.BaseStream)

Dim fileName = Request.QueryString("fileName").ToString() '使用之前POST過來的參數fileName=tempPic.jpg
Using fs = New FileStream("C://cc/" + fileName, FileMode.Create)
fs.Write(byteArrayF, 0, byteArrayF.Length - 1) '從byteArray 寫入 fs stream
End Using
'----------/寫出檔案/----------------
MsgBox("Server 收到完成 創建路徑 C:/cc/")
End Using
End Sub

End Class
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 prague12 的頭像
    prague12

    prague12

    prague12 發表在 痞客邦 留言(0) 人氣()