No probs, I may well use this myself in the near future! 2009/10/20 Bob Silverberg <[email protected]>
> Cool. That looks like it would do the trick. Thanks for taking the time to > do that! > > > On Tue, Oct 20, 2009 at 4:48 PM, Chris Blackwell <[email protected]>wrote: > >> I just took a stab at this, in a very quick and dirty fashion. Stick that >> in a controller and fire it onRequestStart and you're good to go. >> <cffunction name="handleUploads"> >> <cfargument name="event" /> >> >> <cfset var tempDir = getTempDirectory() /> >> <cfset var regex = "^" & replace(tempDir,"\", "\\", "all") /> >> <cfset var i = "" /> >> <cfset var uploads = structnew() /> >> <cfset var result = "" /> >> <cfset var tempFile = "" /> >> <!--- i think its probably ok to access FORM directly here... ---> >> <cfloop collection="#form#" item="i"> >> <cfif REFindNoCase(regex, form[i])> >> <cftry> >> <cfset tempFile = createuuid() /> >> <cffile action="upload" filefield="#i#" >> destination="#tempDir#/#tempFile#" result="result" /> >> <cfset uploads[i] = result /> >> <cfcatch> >> <!--- you might wanna log this error or take some action here ---> >> </cfcatch> >> </cftry> >> </cfif> >> </cfloop> >> <cfset event.setValue("uploads", uploads) /> >> </cffunction> >> >> >> 2009/10/20 Chris Blackwell <[email protected]> >> >> I'm not aware of an actionpack repo, and i'm not sure if any of the >>> exisint actionpacks have been tested against Gesture. But seems like there >>> probably should be one! >>> By the way, just read your blog >>> post<http://www.silverwareconsulting.com/index.cfm/2009/10/20/Detecting-That-A-Form-Field-Contains-a-File>and >>> the regex breaks on windows because you need to escape the backslashes, >>> you need >>> >>> REFindNoCase("^" & replace(tempDir,"\", "\\", "all"), form[fld]) >>> >>> Chris >>> >>> 2009/10/20 Bob Silverberg <[email protected]> >>> >>>> That is a very good idea. Honestly, I haven't used MG much in quite >>>> awhile. Although I poke my nose into the framework code every now and then >>>> I >>>> am kinda rusty from a user perspective. I didn't even think about simply >>>> using onRequestStart to do this - duh. I think that would accomplish just >>>> what I'm talking about, and different actionpacks could be made available >>>> with different implementations. I suppose the only advantage to baking it >>>> into the framework would be that developers wouldn't need to locate and >>>> install an actionpack as a separate step. Is there some sort of repository >>>> for MG actionpacks? >>>> >>>> >>>> Cheers, >>>> Bob >>>> >>>> On Tue, Oct 20, 2009 at 4:20 PM, Chris Blackwell <[email protected]>wrote: >>>> >>>>> Bob, >>>>> I like, and use something along the lines of the first method you >>>>> describe of broadcasting a needFileUpload message with an argument >>>>> defining >>>>> the filefield value, although I'm handling the upload directly in the >>>>> controller rather than in a separate FileUploader component. >>>>> However I'm not convinced there's a need to go to the lengths you >>>>> describe to handle file uploads automatically. This just sounds like an >>>>> actionpack to me. Surely all thats needed is a controller with a method to >>>>> detect uploads, handle them (possibly using supporting cfc's like an >>>>> UploadDetector or FileUploader) then set the metadata into the event, >>>>> which >>>>> is fired onRequestStart. >>>>> >>>>> Chris >>>>> >>>>> >>>> -- >>>> Bob Silverberg >>>> www.silverwareconsulting.com >>>> >>>> >>>> >>> >> >> >> > > > -- > Bob Silverberg > www.silverwareconsulting.com > > > > --~--~---------~--~----~------------~-------~--~----~ Model-Glue Sites: Home Page: http://www.model-glue.com Documentation: http://docs.model-glue.com Bug Tracker: http://bugs.model-glue.com Blog: http://www.model-glue.com/blog You received this message because you are subscribed to the Google Groups "model-glue" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/model-glue?hl=en -~----------~----~----~----~------~----~------~--~---
