News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

sending file (or data) to a URL

Started by jefe, January 01, 2009, 11:20:15 PM

Previous topic - Next topic

jefe

I want to send a file (or a stream data) to a url (internet). Do someone teach me  how do that.

ecube

if you want to upload files to a ftp server you can use http://msdn.microsoft.com/en-us/library/aa384180(VS.85).aspx those can work with http too. To upload a file to a regular web server you need it understand what you wanna do and have something in place to handle the request and uploaded file data (theres alot of simple upload forums written in php you can get/test on) after that just packetsniff your browser when you upload the file and replicate the sent data. Typically the browser sends headers saying wat it wants to do, including the filename and size, thenfollwing that sends a unique string thats not in the data to upload(this signifies the start of the data) then it sends it at the end of the file data to signify the end of the data.

donkey

A E^Cube said the FTP commands are the easiest way to accomplish this, the following is a modified snippet from a bit of code I wrote some time ago, the original worked though I haven't tested the modifications but it should give you a starting point...

FTPUploadFile FRAME FtpURL,UserName,Password,pFtpDir,pFileName
LOCAL CmdLine[MAX_PATH] :B
LOCAL hFtpFind :D
LOCAL hFtpCmd :D

invoke InternetOpen,offset AppName,INTERNET_OPEN_TYPE_PRECONFIG,0,0,0
mov [hInternet],eax

invoke InternetConnect,[hInternet],[FtpURL],INTERNET_DEFAULT_FTP_PORT,\
[UserName],[Password],INTERNET_SERVICE_FTP,NULL,OFFSET dwContext
mov [hFTP],eax

invoke FtpSetCurrentDirectory,[hFTP],[pFtpDir]

invoke lstrcpy,OFFSET CmdLine,"PUT "
invoke lstrcat,OFFSET CmdLine,[pFileName]

invoke FtpCommand,[hFTP],FALSE,FTP_TRANSFER_TYPE_BINARY,OFFSET CmdLine,\
OFFSET IlParam,OFFSET hFtpCmd

invoke InternetCloseHandle,[hFTP]
invoke InternetCloseHandle,[hInternet]

RET
ENDF

"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable