NetTalk Central

Author Topic: File upload  (Read 4309 times)

bramkip

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
    • Intellisoft
    • Email
File upload
« on: October 24, 2007, 03:15:58 AM »
Hi Bruce,

I'm using the File upload function. I want to change the default (uploads) map before saving the record. Which embed point I have to use?

Thanks

Bram

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: File upload
« Reply #1 on: October 24, 2007, 05:07:15 AM »
WebHandler procedure
.renameFile method.

if you look at the renameFile method in the netweb.clw you'll get a good adea as to what you should be doing here.


Cheers
Bruce

bramkip

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
    • Intellisoft
    • Email
Re: File upload
« Reply #2 on: October 24, 2007, 09:59:15 AM »
Hi Bruce,

That's not what I'm looking for. I want to save the documents in an Map based on a projectnumber. The projectnumber is the map name, which is created on inserting a new project.

Thanks

Bram

ccordes

  • Sr. Member
  • ****
  • Posts: 384
    • View Profile
    • Email
Re: File upload
« Reply #3 on: October 24, 2007, 10:37:29 AM »
Here's what I do- I have a similar situation where I need to keep sets of files that users upload.
I use the file upload control.
In the webhandler, I put a couple of embeds -
In the RenameFile method, in the Data section -
szDirName   cstring(256)
... and  After the parent I put this -
   szDirName=(longpath()&'\web\uploads\'&self.getsessionvalue('curOrg'))
   mkdir(szDirName)
   Self.SetSessionValue('Curr_FileName',getfilename(p_filename))

and in the HandleFile method, in the Data section -
szDirName   cstring(256)
... and I put this after the parent-
!Wait for the file to arrive (the parent begins the transfer)
    btime#=clock()
    loop
        if (clock() - btime#) > 1000 !Adjust this to handle different load times
            beep
            break
        end
        if exists(P_Filename)
            Break
        end
    end
   szDirName=longpath()&'\web\uploads\'&self.GetSessionValue('CurOrg')
!szDirName can point to anywhere.
   self.SetSessionValue('CopiedFileName',getfilename(p_filename))
   self.SetSessionValue('ProcessFileName',szDirName)
!I go through a bunch of stuff to create a new filename, but you can use just the p_filename
   szDirName = clip(szDirName)&'p_filename')
   copy(clip(p_filename),szDirName&' ')
   if ~errorcode()
       btime#=clock()
       loop
           if (clock() - btime#) > 500
               beep
               break
           end
           if exists(szDirName)
               remove(p_filename)
               Break
           end
       end
   end


Does this help?

chris
Real programmers use copy con newapp.exe

bramkip

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
    • Intellisoft
    • Email
Re: File upload
« Reply #4 on: October 25, 2007, 04:48:43 AM »
Hi Chris,

Thanks for your example and explanation. I think it's clear to me now.

Best regards,

Bram
« Last Edit: October 27, 2007, 12:50:43 PM by bramkip »