-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cd69137
Showing
16 changed files
with
7,178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
last 2 versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
dist | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["@babel/preset-env"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Upload.aspx.vb" Inherits="Upload" %> | ||
|
||
<!DOCTYPE html> | ||
|
||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head runat="server"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
<title></title> | ||
</head> | ||
<body> | ||
<form id="form1" runat="server"> | ||
<div> | ||
</div> | ||
</form> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Imports System.Web.Services | ||
Imports System.IO | ||
Imports System.Data.SqlClient | ||
Imports System.Data | ||
Partial Class Upload | ||
Inherits System.Web.UI.Page | ||
' 因為js限制不能使用webform方式上傳,需使用ajax,那回傳過來的是一個json字串,asp會自動將變數對應進imageData | ||
' 這部分已經整合進js,所以只需處理asp部分就好 | ||
'回傳樣式: | ||
' { | ||
' imageData: "BASE64編碼" | ||
' } | ||
'參考網址:https://www.aspforums.net/Threads/102983/Pass-Send-Image-data-as-BASE64-string-using-jQuery-AJAX-in-ASPNet/ | ||
|
||
'此句必加,防止引發CSRF或相關登入驗證錯誤 | ||
|
||
<WebMethod(EnableSession:=True)> | ||
Public Shared Sub MoveImages(ByVal imageData As String) | ||
'檔案名稱須包含副檔名 | ||
Dim fileName As String = DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") & ".jpeg" | ||
'儲存路徑,可自行修改,可使用相對路徑或使用那個可以取得當前網頁路徑的那個函數,但我忘記是啥了:D | ||
Dim pathstring As String = "D:\" | ||
Dim destFile As String = Path.Combine(pathstring) | ||
Dim destFile1 As String = Path.Combine(destFile, fileName) | ||
'檢查是否有相同檔名,有就刪除舊的,這邊可以客製化作法 | ||
If File.Exists(destFile1) Then | ||
File.Delete(destFile1) | ||
End If | ||
'使用FileStream將Base64轉成圖片檔案 | ||
Using fs As FileStream = New FileStream(destFile1, FileMode.Create) | ||
Using bw As BinaryWriter = New BinaryWriter(fs) | ||
Dim bytes As Byte() = Convert.FromBase64String(imageData) | ||
bw.Write(bytes, 0, bytes.Length) | ||
bw.Close() | ||
End Using | ||
End Using | ||
End Sub | ||
|
||
End Class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0"?> | ||
<configuration> | ||
<system.web> | ||
<compilation debug="true" targetFramework="4.0"/> | ||
</system.web> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>拍照Demo</title> | ||
</head> | ||
<body> | ||
<video id="webcam" autoplay></video> | ||
<button type="button" id="takephoto">拍照</button> | ||
<button type="button" id="changecam">換相機</button> | ||
<img id="takePhotoCanvas"></img> | ||
<script src="./webcamtools.js"></script> | ||
<script defer> | ||
//建立相機物件 | ||
var a = new window.WebCamTools("#webcam"); | ||
|
||
|
||
//按下拍照鈕拍照 | ||
document.querySelector('#takephoto').addEventListener('click', function() { | ||
|
||
//呼叫物件內拍照方法,後面網址是拍照後檔案要上傳的網址 | ||
a.takeSnap("./Upload.aspx/MoveImages") | ||
}); | ||
|
||
//按下按鈕切換相機 | ||
document.querySelector('#changecam').addEventListener('click', function() { | ||
//呼叫切換方法 | ||
setCamera() | ||
}); | ||
|
||
//獨立出切換相機方法可以重複使用 | ||
function setCamera(){ | ||
a.getCameras().then(function (cameras) { | ||
a.setCamera(cameras); | ||
}).catch(function (e) { | ||
console.error(e); | ||
}); | ||
} | ||
|
||
//當網頁載入時會跳出選擇相機 | ||
setCamera(); | ||
</script> | ||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.