-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uploadAll sending stale formData #225
Comments
if you want to send the form data along with the upload..do it this way |
@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 |
yeah..i don't understand..can u provide a jsfiddle of what you want |
@PawelDecowski , see faq How to update FileItem options before uploading // add all fields
uploader.onBeforeUploadItem = function(item) {
Array.prototype.push.apply(item.formData, uploader.formData);
}; |
@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 |
Nothing. FileItem will be created when the file will be added to queue. In this moment uploader options will be copied to FileItem |
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... |
Thanks it work |
HI. how do I pass formdata. plz advsie. I was trying for long hours. var uploader = $scope.uploader = new FileUploader({ please reply asap. many thanks |
OR My biggest misconception was that the form data is attached to the item and not the uploader. |
one can also do like that, if someone wants to send data on click of button with attached function
|
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. |
@sebastianfelipe you can get your uploaded file on server side within |
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 |
I have a form which, in addition to uploading a file, sends some other fields. For clarity, I send only one field in this example:
Let’s say the value of the
name
input is Test 1.formData
at all.name
field to Test 2 and hit Save. It sends the file andformData
, but the value ofname
it sends is Test 1.name
field to Test 3 and hit Save. It sends the file andformData
, but the value ofname
it sends is Test 2.So it seems to always send the data that was assigned to
formData
before the last call touploadAll
.To clarify: If I do
dir(user, $scope.uploader.formData)
just before callinguploadAll
, it shows correct up-to-date values in both.I’ve been struggling with it for a few hours and just can’t seem to see what’s wrong. Any ideas?
The text was updated successfully, but these errors were encountered: