NetTalk Central

Author Topic: File upload problem  (Read 8556 times)

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
File upload problem
« on: April 01, 2013, 09:05:32 AM »
Hi All,

I am having difficulties getting my web server to accept a file that I need to have a user logged in and send the file name programatically.
The webform is a memory based form and I am validating against a file for the user information and upload folder. Where would I
put the code to verify the user and upload the file. Does not seem to work in the Validate End embed.

Ashley

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: File upload problem
« Reply #1 on: April 01, 2013, 11:05:32 PM »
Hi Ashley,

I'll be away this week, so if you have more questions then hopefully others will step in.

I presume your memory form has a "file upload" field? If so then right-click on the procedure, choose "source" and search for
.SaveFile
then in the embed before that you can use the _Session Value_ of the other fields on your form to do validation - doing an exit before the save if necessary.

cheers
Bruce


astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: File upload problem
« Reply #2 on: April 02, 2013, 03:29:51 AM »
Thanks Bruce! That sounds reasonable, I will try and let you know.

Ashley

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: File upload problem
« Reply #3 on: April 03, 2013, 07:11:16 AM »
Hi All,

I still cannot get the file upload to work. Any one have any suggestions I am all ears!!!

Thanks to anyone ;)

Ashley

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: File upload problem
« Reply #4 on: April 03, 2013, 02:23:42 PM »
why don't you post the code including the embed you are using so we can help

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: File upload problem
« Reply #5 on: April 04, 2013, 03:02:19 AM »
Hi Kevin,

I would but my dev computer died yesterday and should be back today. It's a simple webform in memory mode.

I will get it posted as soon as I can, thank you.

Ashley

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: File upload problem
« Reply #6 on: April 08, 2013, 07:08:58 AM »
All, here is the code I have in my webform(memory). If you see a problem please let me know.


Ashley

[attachment deleted by admin]

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: File upload problem
« Reply #7 on: April 08, 2013, 05:05:05 PM »
I would set some debug points and view with debugview

After

  loc:path = CLIP(p_web.site.uploadspath) &'\'& CLIP(loc:uploadfilename)

add

 p_web._trace(' loc:path=' &  loc:path)
 p_web._trace(' Loc:Login=' &  Loc:Login)
 p_web._trace(' Loc:Password=' &  Loc:Password)

If all these return expected values just add some more traces in your code to see what is executing.


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: File upload problem
« Reply #8 on: April 08, 2013, 08:19:53 PM »
what Kevin said. Also,
does the Access:cmes.Fetch succeed or fail?

cheers
Bruce

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: File upload problem
« Reply #9 on: April 15, 2013, 08:09:12 AM »
Bruce and All,

Great news I have my file upload page working correctly. ;D

But now I have a web client using this code to post a file to the webserver;

  net.SetAllHeadersDefault()
  net.OptionAutoCookie = 1
  net.SetValue('loc__login','demo')
  net.SetValue('loc__password',demo')
  net.SetValue('loc__uploadfilename','c:\temp\TestData04.csv',Net:IsFile)
  net.SetValue('pressedButton','save_btn')
   
  net.Post('http://127.0.0.1:88/UploadFile', '')

File does not get uploaded. UploadFile is the proc on the webserver that will be doing the upload. Am I missing something?

Ashley


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: File upload problem
« Reply #10 on: April 15, 2013, 10:55:47 PM »
Hi Ashley,

in the spirit of teach a man to fish and all that I'm going to answer this by giving some hints as to how to debug the issue.

What you want to do is figure out "where the Post gets to". For example;
a) does it arrive in the web server?
b) does it arrive in the form?
c) does the file get uploaded?
d) does the file get saved?
e) where does it get saved to.

It could "go missing" at any of the above steps, and so narrowing it dow narrows the scope of the problem, and hence the places to look for a solution.

Debugview is your friend in this case - so use that, and the p_web._trace('whatever') statement to track what's happening.

a) does it arrive in the web server?
just watch the "log" window in the server to see if the Post arrives. Look at the post and see if it has a file attached. (The format for posts including files is different to the normal post format, so it's easy to see.)

b) does it arrive in the form?
tick on the option to "send stage to debugview" in the form. You should see the form being called when the Post is sent.
The form in question here is called UploadFile (based on your URL).

c) does the file get uploaded?
check the log as in (a) above - note that you won't actually see the contents of the file if it is a binary file - but you'll see the file name etc.

d) does the file get saved?
there's a field loc:uploadfilename (of type File Upload - NOT HTML 5 uploader) on your form. Which means there's a
savefile::loc:uploadfilename routine
in the procedure. Add a trace statement to see if it gets in there.

e) where does it get saved to.
you'll see the generated call to p_web.SaveFile in that routine.
Add a trace statement to see what the values in the parameter are.

Cheers
Bruce

I presume

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: File upload problem
« Reply #11 on: April 16, 2013, 05:54:36 AM »
Hi Bruce,

Thanks...That is how I debugged it from the website menu, and have it working from the site. Although it was not easy tracing it since there was a bug in the NetTalk.clw that I read about yesterday. After I fixed the trace bug in the clw it then worked, and I resolved my issue with the file upload on the site.

Now Posting it from a Client is a whole new issue. Comparing the two log files they are vastly different! I have my same _trace statements in the proc. Last trace is when changing the save_btn text to 'Save' . The file I am uploading is a CSV file so I do see the contents in debugview and the webserver, but never gets uploaded and/or saved. Looks like the the save_btn never gets pressed or I would see my _trace information after that.

If you would like to look at the log files let me know I will attach them.

Well I caught one fish, but missed another.


Regards,

Ashley

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: File upload problem
« Reply #12 on: April 16, 2013, 07:43:48 AM »
>> Comparing the two log files they are vastly different!

tell us more about this.

cheers
Bruce

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: File upload problem
« Reply #13 on: April 16, 2013, 08:24:56 AM »
Hi Bruce,

I have attached the 2 log files one from the website and the other is from the client.

I do not know what else to tell you. All _trace() calls are under the same embeds.

this is the code I am now using in the client embed
  net.SetAllHeadersDefault()
  net.OptionAutoCookie = 1
  net.SetValue('loc__login','astahl')
  net.SetValue('loc__password','jasx1126')
  net.SetValue('loc__uploadfilename','c:\temp\TestData04.csv',Net:IsFile)
  net.SetValue('pressedButton','save_btn')
   
  net.Post('http://127.0.0.1:88/UploadFile', '')

as you can see in the log files i get the proper response back from the server.

Regards,

Ashley


[attachment deleted by admin]

bruce2

  • Full Member
  • ***
  • Posts: 108
    • View Profile
    • Email
Re: File upload problem
« Reply #14 on: April 17, 2013, 11:56:41 PM »
Hi Ashley,

unfortunately those log files are not helpful because they contain way too much information.
Those are "NetTalk" log files, which is a low-level diagnostic used for debugging the TCP/IP level, whereas for what you're doing we need to see what's happening at a very high level.

So first step - turn off the logging options on the NetTalk global extension.

Also, I think you've maybe gotton a bit stuck, so perhaps now is the time to email me (or post here) your apps & dict etc so I (or others) can take a look at what you are doing, aand perhaps more fully understand the problem you're in. I think the actual problem is probably very simple, but it's hard to debug someone else's program when you can't see the code.

cheers
Bruce