我使用 angularjs 通过 ajax 提交表单以调用我的 mvc Controller 中的操作。和使用我的 Angular 指令,我可以获得所选文件的文件名、内容类型和内容长度。我从 Angular 提取的这三个信息是否足以将文件附加到我的电子邮件中?谢谢大家的帮助。
I can get the filename, contenttype and contentlength of the selected file.
不,这还不足以将文件作为邮件附件发送。没有文件的内容,上述所有详细信息都没有值(value)。
编辑:如果您计划在您的 mvc Controller 中发布 HttpPostedFileBase,那么您可以提取上述详细信息,如下所示。
获取扩展:
string extension = Path.GetExtension(upload.FileName);
其中上传的类型为 HttpPostedFileBase。
获取文件名:
string fileName = Path.GetFileName(upload.FileName);
获取文件类型:
string contentType = upload.ContentType
我是一名优秀的程序员,十分优秀!