PDA

View Full Version : Transferring a file via FTP


PointOfLight
05-21-2008, 06:05 PM
I have attached a simple example of how to FTP a file using the WinSock commands.* For the variables user$ and password$, you can either hard code those with the appropriate values or create variables like I did.* Also, be sure to replace the IP address with the appropriate one for your FTP server.* Finally, I've only tested this on the PC at this point.* I will try it on the PPC when I get home tonight.* If someone gets the chance beforehand, please let us know what you find.* Enjoy!
[br]1211389528_49_FT0_ftp_file.zip

quangdx
05-22-2008, 08:01 PM
amazing,
so simple, which is the best solution,

although i've just tried it on my ppc,
it connects to the ftp but then i get
unable to transfer file...
it works fine on my PC though.

also my other question is, how secure is this going to be?
will people be able to steal my ftp login and password?

PointOfLight
05-23-2008, 06:51 PM
I guess that really depends on how the API works.* If it encrypts the user name and password then you should be fine as far as security is concerned.* I guess I'd look more indepth into the InternetConnect function for an answer to that.

As for the program not working on your PPC, I hate to ask this stupid question, but are you sure the file exists on the PPC and the path is right?* I just tried it on mine and it works just fine (including transferring the file).

quangdx
05-23-2008, 08:15 PM
i'm using

result$ = FtpPutFile(connection$, "hello.txt", "hello.txt", FTP_TRANSFER_TYPE_ASCII, 0);

and placing the hello.txt file in the same direcory as the exe files.
do i need to state the complete path on the PPC.
tested this on both a Vario II(hermes) and Compact III(artemis)
maybe cos they're both running windows mobile 6.1 that may have something to do with it.

quangdx
05-23-2008, 08:24 PM
okay, the probelm was to do with the paths
when running it on my PPC I have to state the complete path for the file.

result$ = FtpPutFile(connection$, "\\Storage Card\\ppl\\hello.txt", "hello.txt", FTP_TRANSFER_TYPE_ASCII, 0);

works all good.
a little bit frustrating, but nothing i can't work around.
cheers eric.

PointOfLight
05-23-2008, 09:05 PM
Actually, if the file is going to be in the same path as the executable, just do

AppPath$ + "hello.txt"

This is what I did and it worked just fine on my PPC.

quangdx
05-24-2008, 02:52 PM
is there any way to read/display the messages the ftp host returns?
errors and confirmations, etc.

the problem I'm having is,
when I try to connect over the phone/gprs network connection, it won't connect to the FTP site.
it's fine when connected via wifi or synced with the USB cable to my PC.
this isn't gonna be very good if i want to write games people will be able to play online while they're out and about on the PocketPC phones.

quangdx
05-24-2008, 05:17 PM
it would seem that my cellular netowrk provider has blocked ftp access,
most likely by blocking port 21.

and i imagine a lot of other network operators have done the same,
this means i'm going to have to find different way to read/write an online hiscore table.
it's back to the drawing board,

thanks eric for all your help.

kornalius
05-24-2008, 09:12 PM
Use regular port 80 (HTTP), the winsock demo uses it. It is the easiest IMHO.

quangdx
05-25-2008, 05:06 AM
but the question is,
how do I use regulare port 80 (HTTP) to write a file to my website?

Nicknack
08-08-2008, 12:46 PM
just want to say that this method is also capable of transfering files between ppcs, using Mocha's Ftp Server (or similar software):http://www.mochasoft.dk/freeware/ftpd.htm ;)