# Nginx 1.4.x file upload multipart ecoded

**URL:** <https://www.ruby-forum.com/t/nginx-1-4-x-file-upload-multipart-ecoded/235958>\
**Category:** NGINX\
**Created:** [July 26, 2013, 2:05am UTC](https://www.ruby-forum.com/t/nginx-1-4-x-file-upload-multipart-ecoded/235958 "2013-07-26T02:05:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [July 26, 2013, 2:05am UTC](https://www.ruby-forum.com/t/nginx-1-4-x-file-upload-multipart-ecoded/235958/1 "2013-07-26T02:05:09Z")

</div>

How I can handle multipart data uploads with the latest nginx release?

The good old upload module won^t compile anymore.

Posted at Nginx Forum:

> **[nginx 1.4.x file upload multipart ecoded](https://forum.nginx.org/read.php?2,241277,241277#msg-241277)**
>
> How I can handle multipart data uploads with the latest nginx release? The good old upload module won^t compile anymore.

---

<div class="post-metadata">

**Author:** ![nenad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nenad](https://www.ruby-forum.com/u/nenad)\
**Post date:** [July 26, 2013, 7:04am UTC](https://www.ruby-forum.com/t/nginx-1-4-x-file-upload-multipart-ecoded/235958/2 "2013-07-26T07:04:18Z")

</div>

Hello!

On Thu, Jul 25, 2013 at 5:04 PM, nenad wrote:

> How I can handle multipart data uploads with the latest nginx release?

Take a look at ngx\_lua module and the lua-resty-upload library:

```
https://github.com/agentzh/lua-resty-upload

```

Best regards,  
-agentzh

---

<div class="post-metadata">

**Author:** ![nenad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nenad](https://www.ruby-forum.com/u/nenad)\
**Post date:** [July 26, 2013, 1:51pm UTC](https://www.ruby-forum.com/t/nginx-1-4-x-file-upload-multipart-ecoded/235958/3 "2013-07-26T13:51:45Z")

</div>

I have the same problem. The upload module was exactly what I needed. I  
don’t understand the complexity of why it can’t be made to work in  
1.4.x+.

---

<div class="post-metadata">

**Author:** ![nenad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nenad](https://www.ruby-forum.com/u/nenad)\
**Post date:** [July 26, 2013, 2:07pm UTC](https://www.ruby-forum.com/t/nginx-1-4-x-file-upload-multipart-ecoded/235958/4 "2013-07-26T14:07:32Z")

</div>

I was looking at resty upload module. I was curious how to store the  
file  
on disk relative to the document root?

For some reason it didn’t work unless I specified the absolute path.

Perhaps I am doing it wrong?

---

<div class="post-metadata">

**Author:** ![nenad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nenad](https://www.ruby-forum.com/u/nenad)\
**Post date:** [July 30, 2013, 1:17am UTC](https://www.ruby-forum.com/t/nginx-1-4-x-file-upload-multipart-ecoded/235958/5 "2013-07-30T01:17:44Z")

</div>

Thank you agentzh, it look as it can do the job.

Do you know if there will be some performance related Issues with usage  
of  
the lua module?

Posted at Nginx Forum:

> **[Re: nginx 1.4.x file upload multipart ecoded](https://forum.nginx.org/read.php?2,241277,241346#msg-241346)**
>
> How I can handle multipart data uploads with the latest nginx release? The good old upload module won^t compile anymore.

---

<div class="post-metadata">

**Author:** ![nenad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nenad](https://www.ruby-forum.com/u/nenad)\
**Post date:** [July 30, 2013, 1:28am UTC](https://www.ruby-forum.com/t/nginx-1-4-x-file-upload-multipart-ecoded/235958/6 "2013-07-30T01:28:50Z")

</div>

Hello!

On Mon, Jul 29, 2013 at 4:17 PM, nenad wrote:

> Do you know if there will be some performance related Issues with usage of  
> the lua module?

The ngx\_lua module was created with performance in mind from day #1  
and quite a few people have been using it in production to prevent  
developing custom nginx C modules. So if you run into any performance  
issues, just let me know.

BTW, you’re recommended to use LuaJIT 2.0+ with ngx\_lua to maximize  
speed.

Regards,  
-agentzh

---

<div class="post-metadata">

**Author:** ![nenad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@nenad](https://www.ruby-forum.com/u/nenad)\
**Post date:** [July 26, 2013, 8:39pm UTC](https://www.ruby-forum.com/t/nginx-1-4-x-file-upload-multipart-ecoded/235958/7 "2013-07-26T20:39:38Z")

</div>

Hello!

On Fri, Jul 26, 2013 at 5:06 AM, David J wrote:

> I was looking at resty upload module. I was curious how to store the file on  
> disk relative to the document root?
> 
> For some reason it didn’t work unless I specified the absolute path.

You can just obtain the document root in Lua via  
ngx.var.document\_root, i.e., accessing Nginx’s built-in variable  
$document\_root:

```
http://wiki.nginx.org/HttpCoreModule#.24document_root

```

So it’s trivial to construct a proper absolute path without assuming  
what the document root is in Lua.

Regards,  
-agentzh
