Comments (4)
Hi,
can you try with
input.append("file", file.fileEntry);
from ngx-file-drop.
I had tried that as well but still no luck. Here is what my web api method looks like:
The byte array is only 18 in length which does not seem correct.
That is with the code change that you recommended:
public uploadFile(file: UploadFile): Observable<string> {
const endpoint = 'uploadfile';
const url = this.uri + endpoint;
let input = new FormData();
input.append("file", file.fileEntry);
return this.http.post(url, input).map(res => res.json());
}
I was able to get the file upload working with a different route which uploaded a type "File" like this:
public uploadFile(file: File){
let formData: FormData = new FormData();
formData.append('file', file, file.name);
this.http.post(this.apiUrl, formData);
}
With that being said I really like how your drag and drop works but I just can't figure out what to change. Is there anything else you can think of?
from ngx-file-drop.
Hi,
can you try with:
file.fileEntry.file(info => {
uploadFile(info);
});
(please check that the uploadFile is called after the file info is taken)
where uploadFile is:
public uploadFile(file: File){
let formData: FormData = new FormData();
formData.append('file', file, file.name);
this.http.post(this.apiUrl, formData);
}
from ngx-file-drop.
That worked! Thank you so much for your help. Here is what my code looks like:
Method in Service:
public uploadFile(file: File): Observable<string> {
const endpoint = 'uploadfile';
const url = this.uri + endpoint;
let input = new FormData();
input.append("file", file, file.name);
return this.http.post(url, input).map(res => res.json());
}
Dropped method (event) in the component:
public dropped(event: UploadEvent) {
this.files = event.files;
for (var file of event.files) {
file.fileEntry.file(info => {
this.vtootService.uploadFile(info).subscribe(res => {
console.log(res);
});
});
}
}
Thanks again!
from ngx-file-drop.
Related Issues (20)
- The type of some files are missing in chrome caused by "webkitGetAsEntry()" HOT 2
- Please publish an Ivy distribution HOT 1
- Complex file extensions don't work for [accept]
- Drag and drop changes content type of .rtf file
- File upload does not recognize content type of Apple Pages file HOT 1
- v14.0.1 break the folder upload function HOT 2
- drop file not working properly sometimes with Chrom, fine with Firefox in Ubuntu HOT 2
- Folders (respectively files in it) cannot be dropped anymore HOT 3
- Accept is working different as in documentation
- Disable drop file not working HOT 1
- Excessively slow with multiple items
- Drop does not work in combination with Windows/MAC and certain browsers
- is it compatible with angular 15 and standalone components HOT 2
- It is not respecting async after update HOT 1
- How to get file size like in the demo
- Feature request: Pass in accept as argument to openFileSelector()
- Missing file when dragged from browser HOT 1
- Why FileSystemEntry not extends FileSystemEntryMetadata
- Drag Drop is accepting Bookmarks links and considering them as files
- Flicker problem when hovering over text HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-file-drop.