Đối với truy cập máy ảnh điện thoại di động từ điện thoại di động, bạn có thể sử dụng thẻ đầu vào như sau:
<input type="file" accept="image/*" capture="camera">
Bây giờ để tải lên các tập tin mà bạn có thể sử dụng onedrive JS SDK như thế này:
<script type="text/javascript" src="https://js.live.net/v7.2/OneDrive.js"></script>
<script type="text/javascript">
function launchSaveToOneDrive() {
var odOptions = { /* ... specify the desired options ... */ };
OneDrive.save(odOptions);
}
</script>
<input type="file" id="fileUploadControl" name="fileUploadControl" accept="image/*" capture="camera">
<button onclick="launchSaveToOneDrive">Save to OneDrive</button>
nơi odOptions sẽ như sau:
var odOptions = {
clientId: "INSERT-APP-ID-HERE",
action: "save",
sourceInputElementId: "fileUploadControl",
sourceUri: "",
fileName: "file.txt",
openInNewWindow: true,
advanced: {},
success: function(files) { /* success handler */ },
progress: function(p) { /* progress handler */ },
cancel: function() { /* cancel handler */ },
error: function(e) { /* error handler */ }
}
Phản hồi thành công của bạn sẽ có URL của OneDriv e tệp được tải lên sẽ được chuyển đến cuộc gọi lại thành công dưới dạng tham số.
{
"value": [
{
"id": "123456",
"name": "document1.docx",
"size": 12340,
"@content.downloadUrl": "https://contoso-my.sharepoint.com/download.aspx?guid=1231231231a",
"webUrl": "https://cotoso-my.sharepoint.com/personal/user_contoso_com/documents/document1.docx",
"thumbnails": [
{
"id": "0",
"small": { "url": "https://sn3302files.onedrive.live.com/..." },
"medium": { "url": "https://sn3302files.onedrive.live.com/..." },
"large": { "url": "https://sn3302files.onedrive.live.com/..." }
}
]
}
]
}
Để biết thêm see: https://docs.microsoft.com/en-us/onedrive/developer/controls/file-pickers/js-v72/save-file)
do đó bạn muốn chụp ảnh bằng máy ảnh iPad và muốn upload nó lên một ổ đĩa. Là bạn muốn? – arunjos007
Có thể không khả thi vì đó là ý tưởng thiết bị/trình duyệt chéo nhưng với các ứng dụng HTML5 ngoại tuyến và tăng hỗ trợ trình duyệt cho các dịch vụ thiết bị (máy ảnh, vị trí địa lý) tôi nghĩ tôi sẽ hỏi. Những gì tôi muốn làm là sử dụng trình duyệt web để yêu cầu ảnh được chụp và lưu trữ trên thiết bị và OneDrive trên thiết bị sẽ chăm sóc đồng bộ hóa tệp trên thiết bị với đám mây vào thư mục OneDrive mà trang web nhận thức được . – Dave