How do I handle local file uploads in electron?

前端 未结 1 538
执念已碎
执念已碎 2020-12-17 14:31

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.

In a standa

1条回答
  •  天涯浪人
    2020-12-17 14:57

    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.

    0 讨论(0)
提交回复
热议问题