NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: ianburgess on June 17, 2012, 01:53:28 AM

Title: Upload file and move to different folder
Post by: ianburgess on June 17, 2012, 01:53:28 AM
I have put a File Upload control on a web form and all works fine - it uploads the file to the \uploads folder.

I need to upload the file to a different folder but cannot see what code to embed and where to embed it. I have come across p_web.RenameFile but not sure exactly how to use it?

My Filename field is DISH:Filename and I wish to upload to the \MemberFiles folder under the main \web folder - can someone suggest the correct code and where to embed?

Many thanks

Ian
Title: Re: Upload file and move to different folder
Post by: estadok on June 17, 2012, 02:37:12 AM
Hi ianburgess!

In Example FileUpload(26) Bruce added some comment in NetWebHandler --> RenameFile method
you can put code like this self.site.UploadsPath = clip(self.site.WebFolderPath) & '\uploads\' &YourFolder before ParentCall
Title: Re: Upload file and move to different folder
Post by: ianburgess on June 17, 2012, 09:00:48 AM
you can put code like this self.site.UploadsPath = clip(self.site.WebFolderPath) & '\uploads\' &YourFolder before ParentCall

Many thanks for the advice. My only remaining issue is where exactly to embed the code. Where in the netwebform procedure should this be embedded? I tried enbedding in the server side code embed of the upload button but this did not work, nor did embedding in procedure setup.

Thanks

Ian
Title: Re: Upload file and move to different folder
Post by: ianburgess on June 17, 2012, 09:49:23 AM
Ok, I just realised that I must embed in the Webhandler procedure and not the form procedure, so embedded the following in Webhandler, renamefile (before Parent):

p_web.site.UploadsPath = clip(p_web.site.WebFolderPath) & p_web.GSV('UploadsSubfolder')


....and in the setup of the form procedure I set the session variable for the uploads folder:
eg.
p_web.SSV('UploadsSubfolder','\uploads\DiscussionFiles')

This way I can have different folders for each form if I want.

Title: Re: Upload file and move to different folder
Post by: estadok on June 17, 2012, 09:58:35 AM
Also you can use the parameter p_path instead of UploadPath.
In form i use ValideteInsert for create folder (path store as session var) and ValidateDelete for delete file from server