iT邦幫忙

0

JQUERY 縮圖上傳問題請教

請問各位先進,關於JQUERY縮圖上傳,例如以下網址:

https://disp.cc/b/11-8uqn

如果我後端是用傳統的ASP(classic asp),我該如何撰寫接收base64轉成圖片檔呢?

謝謝各位

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
fillano
iT邦超人 1 級 ‧ 2016-07-20 10:03:02
最佳解答

classic asp不熟,不過可以幫你找方法:

http://stackoverflow.com/questions/14629104/save-base64-to-an-image-using-classic-asp

接收的話,用Request.Form("base64")應該就可以收到base64編碼的字串,然後再把上面stackoverflow問題跟答案的程式調整一下,應該就可以達到目的。不過因為jquery縮圖上傳這一段會把file type資訊拿掉,可以考慮另外加一個欄位把file type傳到伺服器,不然你不知道要存檔的檔案副檔名應該是什麼。

看更多先前的回應...收起先前的回應...
lungzen iT邦新手 4 級 ‧ 2016-07-20 20:56:43 檢舉

這個我有試過,錯在此行
call bStream.Write( binData )

fillano iT邦超人 1 級 ‧ 2016-07-20 21:35:05 檢舉

哈哈,果然剪貼還是不行的...我測測看XD

fillano iT邦超人 1 級 ‧ 2016-07-20 23:41:21 檢舉

測試檔

我跑過可以把base64的字串轉成png圖檔沒問題,不過我是用JScript寫,如果你是用VB,那可能要調整一下。

lungzen iT邦新手 4 級 ‧ 2016-07-23 14:41:42 檢舉

謝謝給的方向,已經搞定囉,完整如下

base64String =request("base64")
FullName=server.MapPath ("/fileupload/" & filename & ftt)
Set tmpDoc = Server.CreateObject("MSXML2.DomDocument")
Set nodeB64 = tmpDoc.CreateElement("b64")
nodeB64.DataType = "bin.base64" ' stores binary as base64 string
nodeB64.Text = Mid(base64String, InStr(base64String, ",") + 1) ' append data text (all data after the comma)

dim bStream : set bStream = server.CreateObject("ADODB.stream")

bStream.type = 1

call bStream.Open()

call bStream.Write( nodeB64.nodeTypedValue )

call bStream.SaveToFile( FullName, 2)

我要發表回答

立即登入回答