Attach Files to Mandrill Message with Browse Button

前端 未结 2 1349
星月不相逢
星月不相逢 2021-01-19 17:14

I\'m not sure whether this is even possible, but I\'m trying to attach a file to an outgoing email with the Mandrill API from the file upload button (input type=\"file

2条回答
  •  醉梦人生
    2021-01-19 17:57

    I've looked at this extensively, and it appears that it's impossible to use file upload input with the Mandrill API for attachments. A server is required to do anything with a file type="input" because of the security restrictions that have been put into place by browsers.

    I've been able to get around this by using the Ink File Picker API to place a secure download link at the bottom of the email to a file, but this looks a little fishy. It it would obviously be better to do it natively, but, as I've said, that appears to be impossible.

    This compromise, however, is in some ways better than the native way: the Ink API allows users to upload from a variety of services, along with the classic file upload, which improves both the extensibility and the ease of use of the file upload mechanism.

    Using a link for attachments still looks suspicious, but I've been able to minimize the spamminess of the method by using the file name (which the API gives you access to):

    [file name] (hyperlinked to direct download link) was attached to this email.

提交回复
热议问题