久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何處理電子中的本地文件上傳?

How do I handle local file uploads in electron?(如何處理電子中的本地文件上傳?)
本文介紹了如何處理電子中的本地文件上傳?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我很難弄清楚如何在原子電子中處理文件上傳.我會發布代碼,但我什至不知道從哪里開始.

I'm having a hard time figuring out how to approach file uploads in atom electron. I would post code but I don't even know where to begin with this one.

在標準 Web 應用程序中,我會通過標準回發或使用 ajax 請求從客戶端發布到服務器.我有一些非常酷的解決方案.但是在電子的情況下,我不確定在哪里或如何發布"電子.文件回來.我想我只想從 node.js 訪問我的 <input type='file'/> 的內容.我該怎么做?

In a standard web app I would post from the client to the server, either via a standard postback or using an ajax request. I have some pretty cool solutions for that. But in the case of electron, I'm not sure where or how to "post" the file back. I guess I just want to access the contents of my <input type='file' /> from node.js. How do I do this?

我可以發布到瀏覽器進程,但我不知道地址"是什么.將是.或者我需要創建一個單獨的頁面"嗎?在我的應用程序中只是為了接受表單帖子?我在網絡開發方面的背景可能讓我看不到一些明顯的答案,有人可以幫忙嗎?

I could post to the browser process, but I don't know what the "address" would be. Or do I need to create a separate "page" in my app just to accept form posts? My background in web-dev is probably blinding me to some obvious answer, can someone help?

只是為了添加更多上下文,我有一個 .csv 文件,我想允許用戶上傳該文件.然后我將使用 node-csv 處理這個并將每個返回的行插入到應用程序的 nedb 數據存儲中.

Just to add a little more context, I have a .csv file which I'd like to allow the user to upload. I will then process this using node-csv and insert each returned row into the app's nedb datastore.

推薦答案

如果您要在用戶的機器上處理文件,則無需將文件上傳到任何地方,它已經在您需要的地方.您需要做的就是彈出一個對話框,允許用戶瀏覽他們的文件系統并選擇他們希望您的應用程序處理的文件.您可以創建一個按鈕并調用 dialog.showOpenDialog 當用戶按下它時,它會給你一個文件名,然后你可以使用 Node 的 fs.readFile 從磁盤讀取它,然后您可以繼續以任何您想要的方式處理內容.

If you're going to process the file on the user's machine then there is no need to upload the file anywhere, it's already exactly where you need it. All you need to do is popup a dialog to allow the user to browse their file system and select the file they want your app to process. You can create a button and call dialog.showOpenDialog when the user presses it, that will get you a filename and you can then use Node's fs.readFile to read it from disk, then you can go ahead and process the contents in whichever way you want.

這篇關于如何處理電子中的本地文件上傳?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 国产一区二区成人 | 国产一区免费 | 日本一区二区高清不卡 | 久久久国产精品一区 | 国内精品一区二区三区 | 国产精品大片在线观看 | 天天看天天摸天天操 | 欧美日韩视频 | 日日操视频 | 精品久久久久久一区二区 | 欧美99久久精品乱码影视 | 亚洲嫩草 | 国产成人精品一区二区 | 日韩免费一区二区 | 精品成人一区二区 | 精品视频一区二区三区四区 | 青青草精品 | 国产亚洲一区二区三区在线观看 | 午夜在线视频 | av大片 | 黄色免费看 | 亚洲成人精品一区 | 毛片久久久 | 国产精品区二区三区日本 | 成人在线中文字幕 | 欧美日韩免费视频 | 国产视频一区二区 | 亚洲精品视频观看 | 国产午夜精品视频 | 黄a大片 | 天天操综合网 | 狼色网 | 最近最新中文字幕 | 日韩欧美在线视频 | 99re66在线观看精品热 | 狠狠操av| 欧美日韩一区精品 | 香蕉一区二区 | 国产成人在线视频 | 国产成人叼嘿视频在线观看 | 99欧美精品 |