-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
there is only one file in $_FILES when uploading multiple files #475
Comments
post your html here too |
<button
class="form__file"
type="button"
ng-file-select
multiple="true"
ng-model="form.files">
Select file
</button> |
I'm facing the same situation. Don't know if it's related to #1 (comment) that data cannot be transferred along with multiple files. |
you know that the file will not be sent with data: $scope.form, so just remove this or add specific values in your form that you want to actually send or remove the file object from it before sending it. The file should be specified in the ' |
The file is specified in |
Even if I don't write |
Wait what, you have to use the loop to be able to upload multiple files? Also uploading files immediately is just anti-ux. |
For older browsers IE9 you need to upload files one by one. |
Yeah, alright, not using any IE. |
I'm facing the same situation here. Only one file makes it through to my upload controller, even though two or more files were actually selected. I don't have any interest in supporting IE9– anymore, so that's why I was investigating the "array of files" method which was much more intuitive to me. @fxck did you have any success with this issue ? |
Yeah I switched to https://blueimp.github.io/jQuery-File-Upload/angularjs.html which is not ideal, I don't like their angular implementation at all.. but better than nothing. |
Have you tried setting the option |
I just tried it yesterday after leaving my comment (found a Stack Overflow answer suggesting this), and it seems to work (even though I'm not really sure how I was supposed to use this). Thanks for your answer. I chose to use the second syntax ( @fxck did you try setting this parameter ? |
I am closing this issue. Reopen if |
Just to have a feedback for you people, this actually works. The way I made with a dynamic array was: var names = [];
for (var i = files.length - 1; i >= 0; i--)
names.push(files[i].name);
files.upload = $upload.upload({
url: API_BASEURL + '/photo' + $scope.getReqParams(),
method: 'POST',
fileFormDataName: names,
file: files
}); |
Attention: increasing max file size in the server would save you lots of troubles. php.ini - default:
|
For IE9, where does the limitation "one file at a time" come from ? If there is really nothing to be done to bypass this limitation, shouldn't it be specified in the "Old browsers known issues" documentation part ? |
I have 2 file upload controls in my form, it means that I don't want to use same file upload control to upload multiple files. Now please tell me how to handle this situation..? |
@kishor10d just don't add multiple or ngf-multiple to the element and it would just let you select one file. |
@danialfarid : Actually I have 2 file upload controls in my form and according to the ng-file-upload plugin, it can handle only one file upload control in a form(for single file or multiple files). |
What is ng-upload plugin? Are you sure you are on the correct github module? |
@danialfarid : sorry, I MISS the middle word. Its ng-file-upload.. I corrected that in my previous comment. |
@rcbytes solution works! Solution :
Thanks for @rcbytes solution. |
@danialfarid If i try the older version, with the fileFormDataName, i have this error (from angular): Error: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'function (xhr) {..... |
Well nothing worked from the above. I "reindexed" in a new array in order to "lose" the key.
|
I found now this solution: Upload.upload({
url: apiUrl,
fields: params.fields,
file: {"files[]": files}
}) And works well... except that server side i have $_FILES[0], $_FILES[1] etc.... instead of $_FILES["files"][0], $_FILES["files"][1] etc.... For me it's not a big problem... but with many file fields with different logic, it can cause problems. @cwi-ezoutas Which version are you using? With the latest your solution give me the error above... |
请试试 arrayKey: '' ,可是使得服务端接收的 files[0], files[1], files[2] 变成 files数组 |
Hi, I am trying to use this module, but I am getting this error on Laravel Action: $this->errors(['message' => 'Not an image.', 'code' => 400]); This error happens in this if:
My image array: $ngfBlobUrl : "blob:http://ci.dev/e1d8ae23-0ec5-4934-8285-47a956119fe2" My Laravel is returning this error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65461749 bytes) I have already increased my memory_limit from 128M to 512M in php.ini but I am now getting other errors like : Type error: Argument 1 passed to Illuminate\Routing\Middleware\ThrottleRequests::addHeaders() must be an instance of Symfony\Component\HttpFoundation\Response, null given, called in C:\wamp64\www\cadastroimoveis\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php on line 53 I have just copied the example codes with no changes... I am using laravel 5.3 and angular 1.5. Thanks. |
eventhough I'm trying it on the latest chrome, any idea where the problem could be?
$scope.form.files is an array of files
The text was updated successfully, but these errors were encountered: