How do I manage ajax uploads using SWF Upload for concurrent users?
I'm building a simple email functionality in my web application and would like to set it up to be able to send in attachments as well. The thing is that I want to set up the ability to upload files i.e attachemnts asynchronously. I'd like to use SWFUpload for this however 'ajax' uploaders upload the file to a location on the server - that location is m开发者_JS百科ost often prearranged in code or in a config file. In this case I don't want to end up with a situation where concurrent users are uploading files onto this temporary area and they overwrite each other.
How do I set it up. I'm using php MYSQL and the prototype javascript library here.
In this case I don't want to end up with a situation where concurrent users are uploading files onto this temporary area and they overwrite each other.
A good way to avoid this is to generate a random key before the upload process starts, and to prefix every uploaded file with that random key.
When it is time to send the E-Mail, you fetch all the files with that random key.
You could alternatively also create a temporary directory named after the random key, and store all the files there.
That way, you avoid collisions between users and even between multiple upload processes from the same user.
精彩评论