Login  
Search All Forums
Dart Home | PowerTCP Web for ActiveX | Custom Development Reply | PowerTCP Web for ActiveX Topics | Forums   
AuthorForum: PowerTCP Web for ActiveX
Topic: Upload in C
User943

Posts: 7
Member Since: 01/16/01
posted January 16, 2001 11:47 PM

I have reviewed the messages in the Web Tool section. I do not see a clear code example of how to upload a file with the Web Tool in C with no MFC. Some messages point to the samples. But the samples use MFC.
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted January 17, 2001 12:05 AM


While we don't have the exact sample you require, we do have the pieces you need to develop your own implementation.

The PageFetch sample is pretty straight forward. Just remove the MFC stuff and take what you need from it.

Hope this helps!

Tony Priest
Dart Tech Support
User943

Posts: 7
Member Since: 01/16/01
posted January 25, 2001 9:54 PM

Although the pieces may be in the example it is not as easy you state. Could you provide an non MFC example? 10 lines of code? A skeleton? The VB example looks straight forward. I have attempted to pull out the pieces and heading no where.
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted January 25, 2001 10:12 PM


I'm sorry, but there is no such thing as a C++ program that uses controls that's only 10 lines of code. In fact it would take more than that just to create the interface to the object.

The samples are pretty basic. Just add IFtp.cpp and IFtp.h to your project, create a class that inherits from IFtp. Call CoInititialize, call IFtp::Create in the constructor and IFtp::Destroy followed by CoInInititialize in the destructor. This gives you pFtp which is a pointer to an FTP interface.

If you only care about upload, then just look at the DoStore function.

If you still need help, please call in to find out about our consulting services.

Thanks,

Tony
User943

Posts: 7
Member Since: 01/16/01
posted January 25, 2001 10:32 PM

The only problem is I am talking about C not C++. And HTTP posting to a server and not FTP. Instead of a code snippet I have to contact consulting services to find out how to use the control. All I am asking for is an example in C and not pieces of an example in MFC. Is this asking to much?
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted January 25, 2001 10:38 PM


Well, if all you need is a straight C console app, I can do that in about an hour. That's not asking too much I guess. I'll try to do it right now, but I might have to quit.

Just so you know, the idea with the samples is to make them as general as possible so that everyone can get something out of it.

Check back in about an hour to see if I have posted the code.

Thanks,

Tony
User943

Posts: 7
Member Since: 01/16/01
posted January 25, 2001 10:49 PM

Thanks you for your support. A straight C console app example is exactly what I am looking for. I am sure that other customers will find this example useful. Again thank you for your time and support for this product.
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted January 25, 2001 11:07 PM


Here you go. 26 lines in 29 minutes. Not bad. It's actually very easy to use if you don't care about events:

#include "stdafx.h"
#include "stdio.h"
#include "IHttp.h"

int main(int argc, char* argv[])
{
CoInitialize(NULL);
IHttp pHttp;
pHttp.Create(""); // use license from registry
VARIANT Data, Result;
Data.vt = Result.vt = VT_BSTR;
Data.bstrVal = Result.bstrVal = NULL;
try
{
pHttp->PutUrl(_bstr_t("http://www.dart.com/PostSample.asp"));
Data.bstrVal = _bstr_t("Item1=This%20is%20Item%201&Item2=This%20would%20be%20Item%202&Item3=And%20of%20course,%20this%20is%20Item%203");
pHttp->Post(&Data,NULL,&Result,NULL,_bstr_t(""),_bstr_t(""));
wprintf(Result.bstrVal);
}
catch(_com_error e)
{
printf("Error #%d: %s", e.HelpContext, e.Description());
}
pHttp.Destroy();
CoUninitialize();
return 0;
}

Hope this helps!

Tony
User943

Posts: 7
Member Since: 01/16/01
posted January 25, 2001 11:59 PM

Thanks again.
One last thing.
The source complies but I am getting linking errors.
Which lib are you using?
When linking I am getting several unresolved external symbol error messages "public: virtual __thiscall IHttp::~IHttp(void)" (??IHttp@@UAE@XZ).
Are you linking with a Powertcp.lib of some sort?
Or UUID.LIB, MFCS42.LIB, COMPMGR.LIB?
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted January 26, 2001 12:06 AM

I started with the standard Console app project. I then added IHttp.cpp and IHttp.h (which can be found in the PowerTCP directory) Those are the wrappers around our DLL's.

Tony
User943

Posts: 7
Member Since: 01/16/01
posted January 27, 2001 8:10 PM

Tony, thanks for the example if works great with www.dart.com/postsample.asp. Trying to get it to work with my another asp that works via the browser. Any chance of getting the source for postsample.asp so I can find out what is different between the to asp files? And hopefully fix my problem
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted January 27, 2001 8:17 PM


Sorry, I don't have access to that file. You should be able to determine what's wrong based on the response you get back from the server. You're probably need to add a header field like "Referer" or something.

I can't tell you exactly what you need to do, since I don't know what you trying to do.

Tony
User943

Posts: 7
Member Since: 01/16/01
posted January 27, 2001 8:34 PM

Tony, do you ever sleep?
I have not seen support at all hours of the day as you provide.
I am attempting to upload a file via http and an asp server page.
It works via the browser typing in c:\autoexec.bat and hitting the submit button to upload the file. When I take the example C console app that you provided it works with www.dart.com/postsample.asp but not my asp. Trying to figure out the difference between the asp files since your code works and my asp works via the browser.
Tony Priest



From: Utica, NY USA
Posts: 8466
Member Since: 04/11/00
posted January 27, 2001 8:42 PM


I sleep every couple of weeks! Seriously, I'm at home right now. Whenever a message comes in it gets sent to me. If I happen to be in front of my computer, I'll answer it.

I doubt looking at postsample.asp would help much, since as I recall it's a really basic page. Anyway, you'll need to trap the errors or check the reponse from the server to determine what's missing.

Another thing you can do (if you have a browser that can do the post) is use something existing to perform the post and use a packet sniffer to spy on the session.

If you had priority support I could spend a couple hours trying to get this to work for (provided you can furnish the url and other stuff)
You could also get incident support. Contact sales for more info on that.

Thanks,

Tony
Reply | PowerTCP Web for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX