NetTalk Central

Author Topic: Multi-file upload?  (Read 4232 times)

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Multi-file upload?
« on: February 18, 2015, 04:11:09 AM »
Hi All,

I want to upload up to 3 files at a time using a NetWebForm.  File1, File2, File3 and File1 is the only one that would be required. I also need to create a database record on the upload.
Is this possible to upload 3 different files on 1 memory NetWebForm via a POST?

Ashley
« Last Edit: February 18, 2015, 08:15:38 AM by astahl »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Multi-file upload?
« Reply #1 on: February 19, 2015, 03:11:57 AM »
Possible yes, but the form itself will only do 1 file. So you would need to add code to do the other 2. Probably in the ValidateInsert or PostInsert routine.

cheers
Bruce

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: Multi-file upload?
« Reply #2 on: February 19, 2015, 03:39:04 AM »
Hi Bruce,

I decided if they want to upload multiple files they can zip them.

Now another question, does this still work in NT8.34 "net.SetValue('pressedButton','save_btn')"

I cannot seem to get the above to fire when the form is called by a NTClient app.

Ashley
« Last Edit: February 19, 2015, 04:41:39 AM by astahl »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Multi-file upload?
« Reply #3 on: February 19, 2015, 11:48:21 PM »
Hi Ashley,

ahh - I'd completely misunderstood your question. I thought your were talking about updating 3 tables, not uploading 3 actual files - sorry.

The short answer is yes - folks can upload as many files as they like. (There's a template option to allow that.) The files themselves will go into your \uploads\ folder.

But if you need to store those names somewhere - say in a table - you'd need to manually do that yourself (in the saveFile:: routine.).

cheers
Bruce

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: Multi-file upload?
« Reply #4 on: February 20, 2015, 03:11:15 AM »
Hi Bruce,

Yes I think we went down the wrong track. Let me explain better. I have a client app that is used to upload files to my NTServer. The below is the code under the Post button in my client.

  net.SetAllHeadersDefault()
  net.OptionAutoCookie = 1
  net.CanUseProxy = fCon:UseProxy
  IF fCon:UseProxy
    net.Pragma_ = 'No-Cache'     ! Force any proxies to not use their cache. Uses more bandwidth but will contact the webserver directly which is what we want.
    net.CacheControl = 'No-Cache'! Force any proxies to not use their cache. Uses more bandwidth but will contact the webserver directly which is what we want.
  END
!  ThisWebClient.SSLCertificateOptions.CertificateFile = ''
!  ThisWebClient.SSLCertificateOptions.PrivateKeyFile = ''
!  ThisWebClient.SSLCertificateOptions.DontVerifyRemoteCertificateCommonName = DontVerifyRemoteCertificateCommonName
!  ThisWebClient.SSLCertificateOptions.DontVerifyRemoteCertificateWithCARoot = DontVerifyRemoteCertificateWithCARoot
  Attachment = 'C:\BIN\iwif_11242014.csv' ! For Testing
  net.SetValue('uid','test')
  net.SetValue('pwd','test')
  net.SetValue('joborder','915039')
  net.SetValue('filename1',CLIP(Attachment),Net:IsFile)
  net.SetValue('pressedButton','save_btn')
  loc:url = 'www.mycustommailing.com/uploadpage'   
  net.Post(loc:url, '')

I know the post is working because I can see the information on my server when posted.
Everything looks normal but it does not save the file nor does it write to the database any information.
It is like the net.SetValue('pressedButton','save_btn') is not being recognized by the uploadpage webform.

This is all working in another app that is used to upload data files. This app was cloned from another that is working.

Ashley


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Multi-file upload?
« Reply #5 on: February 20, 2015, 06:04:04 AM »
Hi Ashley,

ok I understand now.

Firstly, if you are sending from a client program you may want to explore creating an API on the server side, rather than a form. The client side will remain as a POST, but the server side becomes a little more "formal". My webinar last Friday (ClarionLive #300) is a good place to start.

If you are going to POST to a form instead then there are some things you need to do. I'm guessing you upgraded this from an older NetTalk where this used to work? In earlier nettalks incoming files were just saved. However these days there's a bit more securitry added to the process.

So the short answer is that in order to make this work you would have to first FETCH the form page from the server. (ie your client has to "open the form".) Then you've got your cookies on (good) and you would parse out the FormState variable from the page, and send that back... (From memory that is done automatically, but check the WebClient Drive example that shows the technique.)

Once you've done that, and set the FormState, then you can set the other variables and do a Post.

(you get the idea yet that the API is easier?)

Cheers
Bruce


astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: Multi-file upload?
« Reply #6 on: February 20, 2015, 06:42:19 AM »
Hi Bruce,

Man it sure sounds easier!!!

I will try the new methods first.

Thank you.

Ashley
« Last Edit: February 20, 2015, 07:17:02 AM by astahl »