The requirement is to attach file from local system through local path using Apex. Here file path is give by the client for example 'D:\image\img1'. The same has to be attached to the given record without using VF page. Please provide suggestions to achieve this
2 Answers
Apex doesn't have a access to files on anyones localhost. Apex runs on the servers that Salesforce manages in the cloud and sends the that information to your browser which renders the SF UI.
JavaScript running on the client side would potentially have access to a file uploaded via an <input type="file">
tag; however, it sounds like the requirement is to not use a VF page.
Not sure that this is possible as you've laid out the requirements.
This could be accomplished by creating a desktop application or javascript favelet which takes the file from the user's computer and sends it to Salesforce via an API. The REST API ought to suffice for this purpose, although I've never tried it with large files.