Most of the time if you do need a client file, you could use ASP.Net's file uploaded control to upload files from the client to the server.
This script first uses the ActiveX Scripting.FileSystemObject to read the file, then stores the contents in a hidden field, and lastly submits to the server so it can do whatever it needs with that client data.
Note that you'll need to enable ActiveX objects in the browser, else you'll get an error like: "Error: Number:-2146827859 Description:Automation server can't create object". You can do this by:
- In Internet Explorer > Tools > Internet Options > Security > Custom Level
- Enabling or prompting "Initializing and Script Activex controls not marked as safe"
While this is a cute trick to know, again I emphasize be cautious of using it in any enterprise app due to security reasons.
Post a Comment