NetTalk Central

Author Topic: Copy File to Web folder, serve it, and then delete it from a button click  (Read 5714 times)

BColladay

  • Newbie
  • *
  • Posts: 39
    • View Profile
    • Email
I desire to show a list of documents in a NetWebBrowse, On each row there is a view button which when clicked, would:

copy the file from a location on the hard drive to a folder inside the web folder

Open the document in a new window in the browser

Delete the document from the web folder
--------------------------------------------------------------
Currently I have a browse that using LinkToDoc:

Copies all of the documents associated with that browse when the browse loads.

When the view button is pressed the document is served in a new window and is deleted.

Then if you close the document, the view button won't work because the document no longer exists.


I saw the "send button click to server" insert on the "client-side" tab, can I do something there that would allow me to first copy the correct document into a WEB sub-folder, then open that document in the browser using a currently unknown magic power?  Oh and still delete it after served using $$$?

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Copy File to Web folder, serve it, and then delete it from a button click
« Reply #1 on: November 14, 2010, 03:53:04 PM »
I do a similar thing but don't delete the files when served but when the session is deleted. I also have some cleanup code when I start my web app to clear out any old files that my not have been deleted if the web app was closed before a session was deleted.

BColladay

  • Newbie
  • *
  • Posts: 39
    • View Profile
    • Email
Re: Copy File to Web folder, serve it, and then delete it from a button click
« Reply #2 on: November 15, 2010, 06:18:12 AM »
I need to do something like that too.  However I may need to set a timed event daily to delete strays since I won't manage this server once implemented.

I am having a problem right now on the Android browser, with the $$$ delete system, it deletes the file then Android tries to server the file.  Obviously that doesn't work.

My best case scenario would be to dynamically copy and open the file, then delete the files associated with that session when the session ends. I haven't looked at the session id for naming yet.  But that seems like the best bet.  Thanks

BColladay

  • Newbie
  • *
  • Posts: 39
    • View Profile
    • Email
Re: Copy File to Web folder, serve it, and then delete it from a button click
« Reply #3 on: November 15, 2010, 03:08:33 PM »
I am trying to do manual clean up in WebHandler  p_web.DeleteSession method. this is what I have there


Code: [Select]
lcl:FolderMask = PATH() & '\web\LoggedIn\patdocs\' & p_web.SessionID & '*.*'
DIRECTORY(FileList,lcl:FolderMask,ff_:Directory)
IF RECORDS(FileList) = 0
FREE(FileList)
EXIT
END
LOOP Ptr = 1 TO RECORDS(FileList)
GET(FileList,Ptr)
IF fileQ:ShortName = '.' THEN CYCLE.         !skip non
IF fileQ:ShortName = '..' THEN CYCLE.               !file entries
IF BAND(fileQ:Attrib,ff_:Directory) THEN CYCLE.            !skip sub-folders
REMOVE(fileQ:Name)
END
FREE(FileList)

I have this in my global map embed:
INCLUDE('CWUTIL.INC'),ONCE
I am getting errors indicating that it is not recognizing this include.

Illegal data type: PATH

Expected: <ID> & APPLICATION CLASS FILE GROUP INTERFACE ITEMIZE QUEUE REPORT VIEW WINDOW  -

Unknown attribute: FF_:DIRECTORY -

Expected: <ID> <LINEBREAK> ; CODE INCLUDE OMIT SECTION COMPILE PRAGMA GROUP ITEMIZE MAP  -

Any ideas?  Is that the wrong place for the include?

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Copy File to Web folder, serve it, and then delete it from a button click
« Reply #4 on: November 15, 2010, 10:32:08 PM »
I think you probably just need to indent your code by a couple spaces.

cheers
Bruce

BColladay

  • Newbie
  • *
  • Posts: 39
    • View Profile
    • Email
Re: Copy File to Web folder, serve it, and then delete it from a button click
« Reply #5 on: November 17, 2010, 07:27:53 AM »
It turns out I'm even more clueless than I thought, I was embedding in the Data section rather than the exe section.  For those of you wondering, that doesn't work.  Works beautifully now.

ewilliams

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Copy File to Web folder, serve it, and then delete it from a button click
« Reply #6 on: November 17, 2010, 07:42:58 AM »
Testing, testing ... 1,2,3