# Uploading Multiple Files

**URL:** <https://forum.elixirforum.com/t/uploading-multiple-files/17536>\
**Category:** Questions\
**Tags:** phoenix, file-uploading\
**Created:** [October 25, 2018, 11:08pm UTC](https://forum.elixirforum.com/t/uploading-multiple-files/17536 "2018-10-25T23:08:16Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![OvermindDL1](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/overminddl1/32/2677_2.png) [@OvermindDL1](https://forum.elixirforum.com/u/OvermindDL1)\
**Post date:** [October 26, 2018, 3:18pm UTC](https://forum.elixirforum.com/t/uploading-multiple-files/17536/6 "2018-10-26T15:18:20Z")

</div>

> [@Eiji](#):
>
> Only for standard `HTTP` upload. Is not `WebSockets` standard better for that?

I need to be able to fall back to no javascript and still have it fully work, requirements of my job. ^.^;

> [@Eiji](#):
>
> In your case if you would have a network problem in the middle of process then you would need to send again all of hundred or even few thousand files.

All local network, if there are network issues then there are bigger problems and this suddenly doesn’t matter. Uploading of the _entire_ set is only about 40 megs as it is and this will happen rapidly on some days and then be pretty dead for weeks at a time.

> [@Eiji](#):
>
> Remember that there are still people which do not have fast fiber internet. 😃

Doesn’t matter one tiny iota here, gigabit network. ^.^

> [@Eiji](#):
>
> I think that you should create a `GitHub` issue for this problem in `elixir-plug/plug` .

I don’t want to create a github issue for what seems to be a pure usability issue. This is the first time I’ve needed to upload files to a phoenix server so it’s outside of my realm of knowledge. It works fine in php and with python servers though and those were pretty trivial to get working (iterate a file list).

> [@Eiji](#):
>
> but if I would guess then I think that `plug` is **trying** to handle `multiple` upload as same as normal upload which means that it hits an edge case of `file upload` implementation in `plug` where developers does not expect to parse request content of `multiple` files

I would highly doubt this, it is part of the spec and they seem to follow the spec fairly well for most other things.

> [@Eiji](#):
>
> Also I believe that [Issue when uploading a file with multipart/form-data with Chrome but trying to upload a directory instead of a file](https://github.com/elixir-plug/plug/issues/757) `plug` issue is really similar to your case (not properly handled request content standard).

Hmm, I wonder how this would respond to me trying to upload a directory… testing…  
Edge and Firefox both don’t allow me to upload a directory, only multiple explicit files.

> [@Eiji](#):
>
> Also if you would look on that issue then you would see that different browsers could send requests content in different format, so make sure to test them and give us information about it as in linked issue.

I’ve tested in Chrome, Firefox, and Edge and all had no issues with the PHP test script for them.

> [@Eiji](#):
>
> This means that you need to have multiple `file_input` with `name` which ends with `[]` (because it shows `Phoenix` that we want to save value of multiple inputs into one list). `[]` suffix should not change parsing parameters for only one field. Just instead of `value` you would have `[value]` and nothing more, so it’s useless for you.

Yep, PHP has the same thing, you need to have `[]` at the end of the name for PHP’s built-in handlers to handle it.

> [@Eiji](#):
>
> If I remember it correctly then there needs to be some specification regarding content parsing - probably from `W3C` , but I’m not sure about it. I saw really long specification for `HTML` / `HTML5` document parsing and as it’s related to it (as a part of `<input/>` specification) it should be described well or at least linked to 3rd-party specification page. It may be also described or linked on browser developer pages (like `MDN` ) in contents of `Gecko` or `WebKit` specifications. My last idea are issue trackers with tickets for adding support for it, so there should be a commit(s) which are encoding form to valid request body, so by knowing how it works somebody could write a parser.

Well both PHP (built-in) and Python (flask) had no issues with them? In PHP you just iterate the file list (it’s an array) and in flask you just call `request.file.getlist("files[]")`, it was all super simple (unlike phoenix/plug so far but I still assert it has to be me doing something wrong, at the very least in needs a doc fix though…).

---

_[View the full topic](https://forum.elixirforum.com/t/uploading-multiple-files/17536)._
