BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How can I accept files via form to my Indy HTTP server?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Reiner
Guest





PostPosted: Mon Oct 20, 2003 6:00 am    Post subject: How can I accept files via form to my Indy HTTP server? Reply with quote



How can you decode the TIdHTTPRequestInfo when a form file (input
type="file") is used?

I have hunted high and low (on Google web and groups) on how to do this and
spent a few hours trying demo projects using things like
TIdMessageDecoderMIME (see code below) to no avail.

Basically the server gets the data and I can see it encoded in
TIdHTTPRequestInfo.UnparsedParams but I can't easily do something with it. I
have posted a sample form, and the data that I get when I upload a file, in
the attachments group.
"form upload files"
news:3f93761a (AT) newsgroups (DOT) borland.com

As mentioned above, I have tried decoding this using Indy tools, including
the following code (which incidentally gets into an infinite loop inside
Indy as it fails to handle the end of the stream properly). The following
creates a stream from a selected file.

--

procedure TForm1.Button3Click(Sender: TObject);
var
decoder, temp : TIdMessageDecoderMIME;
outfstream : TFileStream;
filename : string;
idx : integer;
isend : boolean;
begin
idx := 1;
decoder := TIdMessageDecoderMIME.Create(Self);
try
filename := OpenDialog.FileName;
{ open stream }
decoder.SourceStream := TFileStream.Create(filename, fmOpenRead or
fmShareDenyWrite);
decoder.MIMEBoundary := TIdStream(decoder.SourceStream).ReadLn;
decoder.SourceStream.Position := 0;

while Assigned(decoder) do
begin
filename := Copy(filename, 1, LastDelimiter('.', filename)-1) +
IntToStr(idx) + '.msg';
outfstream := TFileStream.Create(filename, fmCreate or
fmShareDenyWrite);
try
temp := TIdMessageDecoderMIME(decoder.ReadBody(outfstream, isend));
finally
FreeAndNil(decoder);
outfstream.Free;
end;
decoder := temp;
inc(idx);
end;
finally
if Assigned(decoder) then
decoder.Free;
end;
end;




Back to top
Reiner
Guest





PostPosted: Thu Oct 30, 2003 4:51 am    Post subject: Re: How can I accept files via form to my Indy HTTP server? Reply with quote



Never mind I guess since I wrote my own unit to decode it. Obviously hardly
anyone has the need to do this.

Is anyone actually running a real Indy web server or am I the only one?

"Reiner" <email (AT) star-tekNSP (DOT) com.au> wrote

Quote:
How can you decode the TIdHTTPRequestInfo when a form file (input
type="file") is used?



Back to top
Martin James
Guest





PostPosted: Thu Oct 30, 2003 5:10 am    Post subject: Re: How can I accept files via form to my Indy HTTP server? Reply with quote




"Reiner" <email (AT) star-tekNSP (DOT) com.au> wrote

Quote:
Never mind I guess since I wrote my own unit to decode it. Obviously
hardly
anyone has the need to do this.

Is anyone actually running a real Indy web server or am I the only one?


There are at leaset two of us, though mine are all on intranets.

What is 'files via form'??

Rgds,
Martin



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Thu Oct 30, 2003 5:51 am    Post subject: Re: How can I accept files via form to my Indy HTTP server? Reply with quote


"Reiner" <email (AT) star-tekNSP (DOT) com.au> wrote


Quote:
Is anyone actually running a real Indy web server
or am I the only one?

Sure, many people are (they are not necessary here in the groups, but they
are out there in the real world). But uploading files via HTTP is not
necessary a common practice. Although HTTP can upload files to a server,
the server has to be able to accept such transfers. FTP handles the scenrio
must better, and in fact most web servers do use FTP to upload files with
instead.


Gambit



Back to top
Reiner
Guest





PostPosted: Thu Oct 30, 2003 5:52 am    Post subject: Re: How can I accept files via form to my Indy HTTP server? Reply with quote

"Martin James" <mjames_falcon (AT) dial (DOT) pipex.com> wrote

Quote:
There are at leaset two of us, though mine are all on intranets.

I'm running a public server with about 5 domains hanging off it and also and
FTP server.

Quote:
What is 'files via form'??

If you have a HTML form and put the following field type in:
<form action="cgi-bin/getfile" enctype="multipart/form-data" method="post">
<input type="file" name="afile">
</form>

What happens is the server receives the file in the RequestInfo but there's
nothing to decode it.



Back to top
Reiner
Guest





PostPosted: Fri Oct 31, 2003 12:13 am    Post subject: Re: How can I accept files via form to my Indy HTTP server? Reply with quote

"Remy Lebeau (TeamB)" <gambit47.no.spam (AT) no (DOT) spam.yahoo.com> wrote

Quote:
But uploading files via HTTP is not
necessary a common practice. Although HTTP can upload files to a server,
the server has to be able to accept such transfers. FTP handles the
scenrio
must better, and in fact most web servers do use FTP to upload files with
instead.

If you have a web site where you invite visitors to upload their own
pictures and comments, for example, you need a form to handle file uploads.
I wish to create this sort of thing on my server. Webmail software also
needs this sort of thing to handle attachments. FTP is not suitable for this
sort of thing. Indy does get the information/files in
RequestInfo.UnparsedParams but it can't be decoded (by any of the tools I
found). It took me half a day but I now have something that decodes it for
me.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.