NetTalk Central

Author Topic: Upload file and move to different folder  (Read 4581 times)

ianburgess

  • Full Member
  • ***
  • Posts: 119
    • View Profile
    • Email
Upload file and move to different folder
« 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

estadok

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
    • EstaSoft
    • Email
Re: Upload file and move to different folder
« Reply #1 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
Clarion 9.0.10376
NetTalk 7.26
SecWin 6.25
StringTheory 1.92

ianburgess

  • Full Member
  • ***
  • Posts: 119
    • View Profile
    • Email
Re: Upload file and move to different folder
« Reply #2 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

ianburgess

  • Full Member
  • ***
  • Posts: 119
    • View Profile
    • Email
Re: Upload file and move to different folder
« Reply #3 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.


estadok

  • Jr. Member
  • **
  • Posts: 84
    • View Profile
    • EstaSoft
    • Email
Re: Upload file and move to different folder
« Reply #4 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
« Last Edit: June 17, 2012, 10:06:04 AM by estadok »
Clarion 9.0.10376
NetTalk 7.26
SecWin 6.25
StringTheory 1.92