Skip to main content
GameDev.net gamedev.net
🔒 Locked

folders

Started by mgazza2 Nov 22, 2003 at 11:29 AM 3 replies 650+ views
Original Post
mgazza2
mgazza2
hi, into: id like to know how i can get a "real" address from a vertual address eg www.gamedev.net is there some function or request i can send to get the real address. i have made a http upload program using wininet and my program needs a real folder address for the server to be able to acept my request to write to a server side file explanation: the folder for the sites html main page isnt stored at www.gamedev.net it will be like www.gamedev.net/www/net/mainpage/ the domain name is just like a link to the folder and the html file help!: i need to get a directory from a domain name is there any way to do this or what? :s end: thanks all.
C-Junkie
C-Junkie
er. No.

Where files on the server are served from is entirely dependant on the system administrator.

What exactly are you trying to do? that post made no sense...
mgazza2
mgazza2
hi,
im not used to posting on the board .

but iv had no help from ee or anything, so

i need to write a file to my sever using wininet

now iv created all the system for that but my server doesnt let me write to the domain name because i need a sub address.

www.mgazzasoft.150m.com is a SubDomain of www.150m.com (ip address''s are the same)

the server alows me to wite files to the sever but they dont write.
because i need this "real" address
there must be some kind of way of retreving the folder where the sites files are stored because i can read all the files using just the domain name???
krez
krez
the HTTP server translates the URL you ask it for into the actual location of the files, and then sends them. i do not think there is any way of finding out where that actually is though.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
mgazza2
mgazza2
thanks alot , beeter help then ee ;D

heres the code for any one who wants it
to get the ip of a server 4 ne 1 who doesnt know run/command ping www.servername.com

procedure tform1.HTTPUpload(Server,UplFile,locFile,user,pass:string);
var
iFileBuffer,iRetBuffer : INTERNET_BUFFERS;
requestHandle,iConnectHandle,create : PHandle;
totalBytes,byteswritten : integer;
buffer : array[0..512] of char;
smem:tfilestream;
begin
smem:=tfilestream.Create(locfile,fmOpenRead);

FillChar(iFileBuffer,sizeof(iFileBuffer),#0);
iFileBuffer.dwStructSize:=sizeof(INTERNET_BUFFERS);
iFileBuffer.Next:=nil;
iFileBuffer.lpcszHeader:=nil;
iFileBuffer.dwHeadersLength:=0;
iFileBuffer.dwHeadersTotal:=0;
iFileBuffer.lpvBuffer:=@buffer;
iFileBuffer.dwBufferLength:=512;
iFileBuffer.dwBufferTotal:=smem.size;
iFileBuffer.dwOffsetLow:=0;
iFileBuffer.dwOffsetHigh:=0;
// connect to the internet
create := InternetOpen(''Mozilla/4.0 (compatible)'', INTERNET_OPEN_TYPE_PRECONFIG , NIL, NIL, 0);
memo1.lines.add(''OpenHandle=''+inttohex(longint(create),8)+#13);
// connect to our server
iConnectHandle:=InternetConnect(create,pchar(server),80,pchar(user),pchar(pass),INTERNET_SERVICE_HTTP,0,0);
memo1.lines.add(''ConnectHandle=''+inttohex(longint(iconnecthandle),8)+#13);
// create the file on the host
requestHandle:=HttpOpenRequestA(iConNectHandle,pchar(''PUT''),pchar(uplfile),nil,nil,nil,INTERNET_FLAG_NEED_FILE,0);
memo1.lines.add(''RequestHandle=''+inttohex(longint(requestHandle),8)+#13);
totalBytes:=0;
if word(requestHandle)>0 then begin
bytesWritten:=sizeof(buffer);
while bytesWritten>=sizeof(buffer) do begin
bytesWritten:=smem.Read(buffer,sizeof(buffer)); //sizeof(buffer));
iFileBuffer.dwBufferLength:=bytesWritten;
iFileBuffer.dwBufferTotal:=bytesWritten;
if not HttpSendRequestEx(requestHandle,@iFileBuffer,nil,0,0) then
exit;
totalBytes:=totalBytes+bytesWritten;
memo1.Lines.Add(inttostr(totalBytes));
end;
end;
InternetCloseHandle(requestHandle);
InternetCloseHandle(iConnectHandle);
InternetCloseHandle(create);
smem.free;
end;

//downloading

procedure HTTPDownload(Remote:String; var Data:string);
var create,file_remote_handlehandle;
Data_written:cardinal;
buffer:array[0..512] of char;
begin

create := InternetOpen(''Mozilla/4.0 (compatible)'', INTERNET_OPEN_TYPE_PRECONFIG , NIL, NIL, 0);
file_remote_handle:=InternetOpenUrl(create, pchar(remote), NiL, 0, INTERNET_FLAG_RAW_DATA, 0);
if file_remote_handle<>nil then begin

repeat
FillChar(buffer,sizeof(buffer),#0);
InternetReadFile(file_remote_handle,addr(buffer),sizeof(buffer),Data_Written);
data:=data+copy(buffer,1,sizeof(buffer));
until Data_Written<=0;



internetclosehandle(file_remote_handle);
end
else begin
MessageBox(0,''Could Not Resolve Host!'',''Error'',0);
end;

internetclosehandle(create);
end;

thanks !

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.