Quote Originally Posted by Edgar H. Peña C. View Post
Hi all

I am testing the way to change the location of the files to upload for each client, I have tried several methods (cWebResourceManager), the last one is:


Code:
 Object oWebFileUploadButton1 is a cWebFileUploadButton
                Set piColumnSpan to 0
                Set psCaption to "Upload File(s)"
                 
                 Function OnFileUpload String sFileName Integer iBytes String sMime Returns String
                       String sPath 
                        Send RegisterUploadFolder   of ghoWebResourceManager "C:\Temporal2" 
                        Get UploadFolder of ghoWebResourceManager True to sPath
                        Move (sPath + "\"+sFileName) to sPath
                        Function_Return sPath
                 End_Function
                 
     End_Object
Some topics of the help is written for experts


Edgar
RegisterUploadFolder is not really something you want to to inside the file upload itself. It's a safety precaution to prevent writing to unauthorized folders. If a malicious end user forges a request with C:/Windows/System32/... as path now, your code will actually allow the upload which is not what you want.

Personally i prefer doing it in central places that get called once upon initialization, like the End_Construct_Object in your WebApp.src for example.

Also, as Samuel mentioned - if you're uploading to subfolders, you only have to register the root folder and any subfolder will be accepted too.
So for
AppPath/MyUploadFolder/Client1
AppPath/MyUploadFolder/Client2
AppPath/MyUploadFolder/Client3
etc.

you can just register AppPath/MyUploadFolder and it will work!