You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if you want to send the form data along with the upload..do it this way
var uploader = $scope.uploader = new FileUploader({
url:'someUrl',
formData:[]
})
uploader.onBeforeUploadItem = function(item) {
item.formData.push({kf_Upload: $scope.dynamicUploadID['kf_Upload']});
}
Reacted by captainjoko737, iamawebgeek and YachenLi
@sraparla I can’t do it this way because I don’t know the values of the fields at the time of instantiation of the FileUploader class. The form fields can be edited by the user after the class has been instantiated so I need to be able to assign the formData after the user has hit Save and before calling uploadAll.
@nervgh Thanks, that works. But what fixed it? Because you’ve changed a couple of things. Is it the use of the callback, or the fact that you attach the data to a FileItem, rather than to the FileUploader?
how do I pass formdata. plz advsie. I was trying for long hours.
I need to pass these three datas along with the file.
accountList: $scope.accountList.Value,
filedescriptor: $scope.filedescriptor,
txntypename: $scope.txntypename
var uploader = $scope.uploader = new FileUploader({
url: 'en/external/bmls/batches/uploadbatch.bml',
formData:[]
});
On the server side, how can you get the data in that formData? I can't find it, I tried in req.body, req.query, req.params, ctx.args (loopback nodejs). Thanks.
mmm... I can't receive anything in those variables, I'm using loopback, and in the beforeRemote method it still without appear. In the afterRemote method I can get access at the file variable, but not before. I would like to use the req.body, that is the only but it appears after the whole file has been uploaded, and is late to do some staff, like reject the file :c
Activity
sraparla commentedon Aug 27, 2014
if you want to send the form data along with the upload..do it this way
var uploader = $scope.uploader = new FileUploader({
url:'someUrl',
formData:[]
})
uploader.onBeforeUploadItem = function(item) {
item.formData.push({kf_Upload: $scope.dynamicUploadID['kf_Upload']});
}
PawelDecowski commentedon Aug 27, 2014
@sraparla I can’t do it this way because I don’t know the values of the fields at the time of instantiation of the
FileUploaderclass. The form fields can be edited by the user after the class has been instantiated so I need to be able to assign theformDataafter the user has hit Save and before callinguploadAll.sraparla commentedon Aug 27, 2014
yeah..i don't understand..can u provide a jsfiddle of what you want
nervgh commentedon Aug 29, 2014
@PawelDecowski , see faq How to update FileItem options before uploading
PawelDecowski commentedon Aug 29, 2014
@nervgh Thanks, that works. But what fixed it? Because you’ve changed a couple of things. Is it the use of the callback, or the fact that you attach the data to a
FileItem, rather than to theFileUploader?nervgh commentedon Aug 29, 2014
Nothing. FileItem will be created when the file will be added to queue. In this moment uploader options will be copied to FileItem
stephaneeybert commentedon Sep 29, 2014
I'm still puzzled...
First I wonder what is the difference between the options attribute and the uploader.formData property.
Second, I also was pushing the uploaded formData onto the file item formData with:
But doing this would duplicate the file item formData item object and have a formData array of length 2 instead of 1 element.
Here is how I set my uploader.formData property:
So I removed the call: Array.prototype.push.apply(item.formData, $scope.uploader.formData);
Now I only do the:
And it works fine.
But I sense I don't fully understand the thing...
rboughani commentedon Oct 10, 2014
Thanks it work
mani242530 commentedon Nov 4, 2014
HI.
how do I pass formdata. plz advsie. I was trying for long hours.
I need to pass these three datas along with the file.
accountList: $scope.accountList.Value,
filedescriptor: $scope.filedescriptor,
txntypename: $scope.txntypename
var uploader = $scope.uploader = new FileUploader({
url: 'en/external/bmls/batches/uploadbatch.bml',
formData:[]
});
please reply asap. many thanks
michaelmccarver commentedon Apr 7, 2015
OR
onBeforeUploadItem: function (item) {
var stuff = {
profiles: [1426, 1427, 1428],
profiles_groups: '',
upload_type: 'BROWSER',
username: $scope.username,
file_name: item.file.name,
file_size: item.file.size,
file_type: item.file.type,
file_created_date: 135479928,
}
item.formData.push(stuff);
},
My biggest misconception was that the form data is attached to the item and not the uploader.
@nervgh Great tool, thanks for your hard work...
yasharma commentedon Jul 31, 2016
one can also do like that, if someone wants to send data on click of button with attached function
save()$scope.postwill contains your data eg.title, body.sebastianfelipe commentedon Oct 17, 2016
On the server side, how can you get the data in that formData? I can't find it, I tried in req.body, req.query, req.params, ctx.args (loopback nodejs). Thanks.
yasharma commentedon Oct 18, 2016
@sebastianfelipe you can get your uploaded file on server side within
req.fileand data would be inreq.body.sebastianfelipe commentedon Oct 18, 2016
mmm... I can't receive anything in those variables, I'm using loopback, and in the beforeRemote method it still without appear. In the afterRemote method I can get access at the file variable, but not before. I would like to use the req.body, that is the only but it appears after the whole file has been uploaded, and is late to do some staff, like reject the file :c