Article View: borland.public.cppbuilder.internet.web
Article #1015Re: CGI how to write program for accepting file uploaded to server
From: zhangsn
Date: Sun, 23 Oct 2005 11:52
Date: Sun, 23 Oct 2005 11:52
59 lines
3397 bytes
3397 bytes
Hans, First , Please receive my appreciation for your help. I know "> GET requests (with QUERY_STRING) and POST requests (CONTENT_LENGTH > and readig from STDIN)." But I dont know POST WHAT TO SERVER.(Their format). Whether it is defined in RFC. I want to know this in detail. And I dont know "boundary". How to get the "boundary" and get the data in the uploadfile. I want to know whether this upload file size is limmited. and when the web server active my CGI, if the full data in this upload file(maybe it is a big file) have been all in the "stdin". Now after i read you wrote, I think :Every time I read from this stdin first I will meet this header like this: "Content-Disposition: form-data; name="userfile4"; filename="e:\a2x.txt" Content-Type: text/plain" follow this, It is its data upload. but how to decided its size. how to decided next upload entry where start. I do not start to write code. because it is my touch on CGI at the fourth day. I want to get some experience and solve this "boundary" problem. I search many souce code on internet and they did not mentioned how to solve this problem at all. did you have any good advice on this ? Rgds john "Hans Galema" <notused@notused.nl> :435b67d8$1@newsgroups.borland.com... > zhangsn wrote: > > "<form enctype="multipart/form-data" > > action="http://192.168.29.65/UploadFile" method=post> > > Is receiving an uploaded file the only thing your cgiprogram > should do ? I like to know if you already know how to handle > GET requests (with QUERY_STRING) and POST requests (CONTENT_LENGTH > and readig from STDIN). > > For your uploaded file you read the contents from STDIN because > the REQUEST_METHOD POST is used. There are also all kinds of > headers to be read from STDIN first. > > You will see things like: > Content-Disposition: form-data; name="userfile4"; filename="e:\a2x.txt" > Content-Type: text/plain > > Sadly enough you have to check Content-Type: as the protocol/coding > is different for different types of files. > > Please tell more about what you already know and show the > code where you tried to handle the upload and tell what kind of > difficulties you encountered. > > Hans.
Technical Details
Message-ID:
<435b780e@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<435a2142@newsgroups.borland.com> <435a3d89@newsgroups.borland.com> <435a4548$1@newsgroups.borland.com> <435ad565@newsgroups.borland.com> <435b67d8$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,943780c8a609b3ea X-Google-Attributes: gidfeeec,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "zhangsn" <zhangsn98@sohu.com> From: "zhangsn" <zhangsn98@sohu.com> Newsgroups: borland.public.cppbuilder.internet.web References: <435a2142@newsgroups.borland.com> <435a3d89@newsgroups.borland.com> <435a4548$1@newsgroups.borland.com> <435ad565@newsgroups.borland.com> <435b67d8$1@newsgroups.borland.com> Subject: Re: CGI how to write program for accepting file uploaded to server Date: Sun, 23 Oct 2005 19:52:29 +0800 Lines: 61 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 219.149.28.53 Message-ID: <435b780e@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1130067982 219.149.28.53 (23 Oct 2005 04:46:22 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!news-out.newsfeeds.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail