>> I am trying to implement a file upload utilizing Plupload and its chunk
methodology 

>> I can't seem to solve for when the user opens a new browser window and
proceeds 
>> to upload the same file OR file with the same name as is already
uploading.  

Just in case anyone might find this of interest I finally found a way,
thanks to Maureen in another thread, to attach a UUID or unique file ID to
the multipart upload form fields in the Plupload jQuery uploader queue
widget implementation.  Thanks to an article I found by Ben Nadel
(http://www.bennadel.com/blog/2506-storing-per-file-multipart-params-in-the-
plupload-queue.htm) 
I was able to hook into the widget events and inject new multi-part
parameters for each file in the queue and then write them on the server
using the UUID as a file name, check to see if another file of the same name
exists and re-name the new file with an incremented file name.

Here is the JS for the PLupload queue widget: (note the uuid(); function
script is in my other post)

        // Retrieving a reference to plupload.Uploader object
        var uploader = $('#uploader').pluploadQueue();
                uploader.bind('BeforeUpload', function(up) {
                     up.settings.multipart_params.fileuuid = uuid();
                });

And on the server side:

<cfif FileExists("#chunkdir##trim(form.name)#")>
        <!--- 
        // add an increment to the file until we find one
        --->
        <cfset flext=listlast(trim(form.name),".")>
        <cfset
flname=mid(trim(form.name),1,Len(trim(form.name))-len(flext))>
        <cfset index=1>
        <cfset IsFile=1>
        <cfloop condition="IsFile eq 1">
                <cfset newname=flname & "("& index &")" & "." & flext>
                <cfif FileExists("#chunkdir##trim(newname)#")>
                        <cfset IsFile=1>
                <cfelse>
                        <cffile action="RENAME"
source="#chunkdir##trim(form.fileuuid)#" destination="#chunkdir##newname#">
                        <cfset IsFile=0>
                </cfif>
        <cfset index=index+1>
        </cfloop>
<cfelse>
        <cffile action="RENAME" source="#chunkdir##trim(form.fileuuid)#"
destination="#chunkdir##trim(form.name)#">
</cfif>


This will NOT work with the Jquery UI widget implementation since they don't
seem to (easily) expose the events needed like 'BeforeUpload'.

I hope this helps someone.



Dennis Powers
UXB Internet - A website Design and Hosting Company
P.O. Box 6028, Wolcott, CT 06716 - T:203-879-2844
W: http://www.uxbinternet.com
W: http://www.ctbusinesslist.com


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358812
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to