question

6666666 avatar image
0 Votes"
6666666 asked Bruce-SqlWork answered

How to upload a image in javascript?

I am using abp vnext and there is a DTO in the api.


 const fd = new FormData();
             fd.append("file", document.getElementById('file1').files[0]);
    
    
 $.ajax({
                 url: '/api/app/merchant/image?Name=s',
                 type: "POST",
                 method: "POST",
                 data: fd,
                 contentType: false,
       cache: false,
                 processData:false,
                 success: function (e) {
    
                 }
             });

there is a IRemoteStreamContent in the api.

but if I upload there is an error:

 Deserialization of interface types is not surpported type Volo.Abp.IRemoteStreamContent.

the interface is :

 string FileName{get;}
    
 string ContentType{get;}
    
 Stream GetStream();

how to fix it?

dotnet-aspnet-core-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

your javascript is doing a standard form file post. as for how the server supports this, see abp vendors documentation and ask the question there:

a quick search on their site::

https://community.abp.io/posts/file-uploaddownload-with-blob-storage-system-in-asp.net-core-abp-framework-d01cbe12

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.