NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: astahl 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
-
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
-
Thanks Bruce! That sounds reasonable, I will try and let you know.
Ashley
-
Hi All,
I still cannot get the file upload to work. Any one have any suggestions I am all ears!!!
Thanks to anyone ;)
Ashley
-
why don't you post the code including the embed you are using so we can help
-
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
-
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]
-
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.
-
what Kevin said. Also,
does the Access:cmes.Fetch succeed or fail?
cheers
Bruce
-
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
-
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
-
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
-
>> Comparing the two log files they are vastly different!
tell us more about this.
cheers
Bruce
-
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]
-
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
-
Hi Bruce,
Well wouldn't you freaking know it, I got it working now! ;D
I had it in the embed under "ValidateUpdate|End" and it just would not get to that point with the POST.
I then put the code in the embed under "GenerateForm|SaveButtonSet|3 After Save", figuring that the Save Button had to pressed and It worked finally!
Do you have any thoughts of this being a problem at anytime?
Regards,
Ashley