Keep in mind that HTML is a stateless protocol. So you need to find ways around it. There are 2 ways I use currently,

1st is to use session variables that the server updates as it goes thru the process and the client does ajax calls at set intervals checking the session variables (or maybe a database table) for status updates.

2nd method I use is right here:
http://www.bennadel.com/blog/1244-coldfusion-jquery-and-ajax-file-upload-demo.htm

I use that to upload photos and when the system is done processing them it tells the client to move to the next step.



On 6/8/2014 11:02 PM, Jason Allen wrote:
Hey Guys!

I have a real world design issue I'm starting to get stuck on.

I want users to be able to upload images.

When the image is uploaded, I'm going to run it against some imagemagick functions to create thumbnails, and some alternate sizes.

Along with the resizing.

As it is right now, I send an ajax/json request to a remote cfc, and get a response saying that it's been completed successfully or there's an error. What I'd like to do is have the client updated as various steps in the process are completed.

I could breakup the client request into several steps, but I need to make sure this is a complete process in total. If I let the client initiate each step after getting notice that the current process completed, the total process could fail much more easily. Once the server gets the file, it can do everything about without any further client input. The first few steps are pretty quick AND the client can pretty much move on once they are done. But the last step might take awhile.

So I'm thinking I can just make a template for file uploads in general.



1. Client sends request to imageUpload.cfc with file and file details posted to the request.

2. Server processes file, modifies details (name, extension) if necessary, saves to disk, creates database entry, and pushes update to client.

3. Server beings processing of subroutines. Image resizing, virus checks, etc. As each routine finishes, server pushes update to client.

4. Upon total completely of process, server pushes update to client saying entire process is completed. This could allow user to move onto doing different things, and get an alert saying the file upload/processing has completed.


Best way to do this? I'm seeing some hack ways to use javascript to keep open http requests and you just flush data out to it. But apparently it's really just a hack and isn't dependable across all browsers.


Here's what I'm thinking, and I'm leaning towards B as being the most reliable way to utilize standard ajax functionality.

a) Send each individual request one at a time to keep the requests simple post/respose? I don't like this because it requires the client to initiate each process creating an unnecessary dependancy on the client to complete the full process.

b) Create a temp file or database record that is updated as the server finishes processes. The client can query this for updates at a set frequency. When completed, delete record/file.


Thoughts? If I could keep an open connection with the client, that'd be awesome, cause I could then just push updates.
--
--
online documentation: http://openbd.org/manual/
http://groups.google.com/group/openbd?hl=en

---
You received this message because you are subscribed to the Google Groups "Open BlueDragon" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

--
--
online documentation: http://openbd.org/manual/
http://groups.google.com/group/openbd?hl=en

--- You received this message because you are subscribed to the Google Groups "Open BlueDragon" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to