user1105192
user1105192

Reputation: 412

php temp file upload directory - off local server

When uploading an image PHP stores the temp image in a local on the server.

Is it possible to change this temp location so its off the local server.

Reason: using loading balancing without sticky sessions and I don't want files to be uploaded to one server and then not avaliable on another server. Note: I don't necessaryly complete the file upload and work on the file in the one go.

Preferred temp location would be AWS S3 - also just interested to know if this is possible.

If its not possible I could make the file upload a complete process that also puts the finished file in the final location.

just interested to know if the PHP temp image/file location can be off the the local server?

thankyou

Upvotes: 1

Views: 783

Answers (2)

Roman Newaza
Roman Newaza

Reputation: 11690

You can mount S3 bucket with s3fs on your Instances which are under ELB, so that all your uploads are shared between application Servers. About /tmp, don't touch it as destination is S3 and it is shared - you don't have to worry.

If you have a lot of uploads, S3 might be bottleneck. In this case, I suggest to setup NAS. Personally, I use GlusterFS because it scales well and very easy to set up. It has replication issues, but you might not use replicated volumes at all and you are fine.

Another alternatives are Ceph, Sector/Sphere, XtreemFS, Tahoe-LAFS, POHMELFS and many others...

Upvotes: 1

Andrew M
Andrew M

Reputation: 4288

You can directly upload a file from a client to S3 with some newer technologies as detailed in this post:

http://www.ioncannon.net/programming/1539/direct-browser-uploading-amazon-s3-cors-fileapi-xhr2-and-signed-puts/

Otherwise, I personally would suggest using each server's tmp folder for exactly that-- temporary storage. After the file is on your server, you can always upload to S3, which would then be accessible across all of your load balanced servers.

Upvotes: 1

Related Questions