NetTalk Central

Author Topic: Upload where in Webhandler?  (Read 4626 times)

Nick

  • Full Member
  • ***
  • Posts: 118
    • View Profile
    • Email
Upload where in Webhandler?
« on: April 09, 2014, 04:07:44 PM »
With this html I upload a file to the (NT7) webserver:

<form id="myid" enctype="multipart/form-data" method="post" action="#">
   <input id="fileupload" name="myfile" type="file" />
   <input type="submit" value="submit" id="submit" />
</form>

I see it in the log-post-window of the webserver. Filename, content-length, all is there:

POST /_CONTACT HTTP/1.1
Host: localhost
Connection: keep-alive
Content-Length: 63382
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://localhost
User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MLSROX1S3Hs9fiY
Referer: http://localhost/_CONTACT
Accept-Encoding: gzip,deflate,sdch
Accept-Language: nl-NL,nl;q=0.8,en-US;q=0.6,en;q=0.4
Cookie: SESSIONID=582481416

------WebKitFormBoundary7MLSROX1S3Hs9fiY
Content-Disposition: form-data; name="myfile"; filename="NetTalk.htm"


Question: where/how can I get to this in the webhandler.
Tried a few things in the handlefile and GetContent but no luck.
Which var's hold the filename and content?

TIA,
Nick

Nick

  • Full Member
  • ***
  • Posts: 118
    • View Profile
    • Email
Re: Upload where in Webhandler?
« Reply #1 on: April 10, 2014, 03:49:00 AM »
Have it working by using Self.SaveFile('myfile')
The manual says that this is the default working of the server so then why do I have to use this method?

Nick

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Upload where in Webhandler?
« Reply #2 on: April 10, 2014, 05:05:22 AM »
Files are not saved in WebHandler, as they were in NT6. They are saved by the form itself. So ideally you want a NetWebForm procedure called _Contact, with a File Upload field on it called myfile.

cheers
Bruce

Nick

  • Full Member
  • ***
  • Posts: 118
    • View Profile
    • Email
Re: Upload where in Webhandler?
« Reply #3 on: April 10, 2014, 08:52:12 AM »
Thanks, yes I know but this is a special app that doesn't use the templates and so works different.
Is there some method that I can use to see if the file upload is completed?

Cheers,
Nick

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Upload where in Webhandler?
« Reply #4 on: April 10, 2014, 09:29:17 AM »
I'm not sure I understand the question. Complete _where_ ? Into the WebServer?
Into the WebHandler?

cheers
Bruce

Nick

  • Full Member
  • ***
  • Posts: 118
    • View Profile
    • Email
Re: Upload where in Webhandler?
« Reply #5 on: April 10, 2014, 12:10:46 PM »
Well, I mean the moment when the uploaded file has been saved to disk.
That's what I mean by completed.
I use the .SafeFile() method in the Webhandler.
I guess this is working async. so it may be hard to tell when the file is completely saved on disk (?)


Cheers,
Nick

Nick

  • Full Member
  • ***
  • Posts: 118
    • View Profile
    • Email
Re: Upload where in Webhandler?
« Reply #6 on: April 10, 2014, 02:02:41 PM »
Would the exists() function do well here?

Cheers,
Nick

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Upload where in Webhandler?
« Reply #7 on: April 10, 2014, 09:15:09 PM »
oh, no, not at all. SaveFile is "sync". The whole file has arrived by the time you are in the webHandler and are calling Save. So if you want to add code after SaveFile then just do it there.

cheers
Bruce