Comments (10)
I just pulled the latest from NPM and this is working. You can append additional form data by using the onBuildItemForm handler on FileUploader:
this._uploader.onBuildItemForm = (item, form) => {
form.append("key", "value");
};
from ng2-file-upload.
I couldn't find a multipart support in the last release version. This topic is still open ?
from ng2-file-upload.
First, get a simple example working. The demo has a lot going on so that may be confusing you. In your simple example component you will instantiate a new Uploader - https://github.com/valor-software/ng2-file-upload/blob/development/demo/components/file-upload/simple-demo.ts. In your case you want to post additional form data so I assume you will have an uploader input (<input type="file" ng2FileSelect [uploader]="uploader" />
) and several other inputs. You want to make the submit button on your form call a method in your component that gets the data from the form, uses the code I posted, and then calls uploadAll on your Uploader instance. Something like this (not tested):
<b>
private onFormSubmit() {
// write some code to get the data from the form here.
this.prepareUploader(your form data here);
this.uploader.uploadAll();
}
private prepareUploader(formData) {
this.uploader.onBuildItemForm = (item, form) => {
for (let key in formData) {
form.append(key, formData[key]);
}
};
// continue configuring uploader setting onSuccessItem, onCompleteAll, and other handlers.
}
from ng2-file-upload.
There was a merge error/problem on that PR, as far as I could see from the comments.
+1 for this feature as we need it too - thank you.
from ng2-file-upload.
+1 for this idea. It would be very reasonable to be able to provide additional values with the request because you need more data when saving a file like I need artist name, year and other stuff
from ng2-file-upload.
please check, PR with such feature was merged and published
from ng2-file-upload.
@dmarginian do you have an example of this working? Like with either drag/drop or just a single upload input?
from ng2-file-upload.
The code sample I posted is the relevant code needed to post additional form data. If you need example code on how to use the uploader in general I suggest looking at the demo source - https://github.com/valor-software/ng2-file-upload/tree/development/demo.
from ng2-file-upload.
@dmarginian I guess what I'm trying to ask is how I use the code in context with the demo code? I'm not sure how the two work together?
from ng2-file-upload.
oh wow, now i see it. that's pretty cool, thanks! :)
from ng2-file-upload.
Related Issues (20)
- Release Angular 15 compatible ng2-file-upload package (version 4.0.0 should get tagged as latest) HOT 6
- Angular v13 peerDependency support was removed
- Angular 16 Support HOT 4
- version 1.4.0 not compatible with Ivy engine HOT 1
- Make url optional
- Drag Folder With Files
- Dealing with UploadAll Function
- Existing Files - Add to upload queue as already completed
- .upload() uploads all files, not just one
- Inquiry About Code Contribution Procedure
- Angular V17 support HOT 12
- Directive not recognized even though Module is included HOT 1
- Blob.type is empty can still pass the Mime filter
- Could the file upload widget support pasting a buffered image from clipboard?
- ng2FileSelect not clickable HOT 1
- Angular 18 Support HOT 6
- Impossible to select file with the same name twice in select single mode HOT 1
- Support for Angular 18 HOT 2
- How to upload large files in parts
- release v7.0.1 is not the latest according to npm HOT 1
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 ng2-file-upload.