Check for tempdir once

At this time we create a temp file on each time that upload was requested. For applications that have a lot of upload requests, application may stay slow.

So with this change we create a temp file once, and store the reference in a attribute.