ISAPI file upload
am 10.09.2007 13:26:59 von Kniffel
Hi everyone
I am writing a ISAPI extension, running on a Windows CE webserver. I
now want to extended my ISAPI with a file upload. There are a lot of
examples on file upload with ASP, but I cannot find a really good
example on doing it with an ISAPI extension.
The only thing I have till now is the Output of the content I get when
I upload a txt-file:
....
if(!_stricmp("POST", pECB->lpszMethod)) {
const char multipartContentType[] = "multipart/form-data";
if(!_strnicmp(multipartContentType, pECB->lpszContentType,
sizeof(multipartContentType) - 1)) {
PSTR pszTrav = (PSTR) pECB->lpbData;
printf(pszTrav);
}
}
This prints the content of the txt-file to the console output.
When uploading a different file, like a .exe or a .bin, the printf is
making a error. This is OK because the content is not only text.
How I have to write the uploaded content to a file? Just with
CreateFile and WriteFile?
What when I upload .exe or .bin files, do I have to read/write the
content otherwise?
Greetings
Kniffel
Re: ISAPI file upload
am 11.09.2007 05:31:03 von David Wang
On Sep 10, 4:26 am, Kniffel wrote:
> Hi everyone
>
> I am writing a ISAPI extension, running on a Windows CE webserver. I
> now want to extended my ISAPI with a file upload. There are a lot of
> examples on file upload with ASP, but I cannot find a really good
> example on doing it with an ISAPI extension.
>
> The only thing I have till now is the Output of the content I get when
> I upload a txt-file:
>
> ...
> if(!_stricmp("POST", pECB->lpszMethod)) {
> const char multipartContentType[] = "multipart/form-data";
> if(!_strnicmp(multipartContentType, pECB->lpszContentType,
> sizeof(multipartContentType) - 1)) {
> PSTR pszTrav = (PSTR) pECB->lpbData;
> printf(pszTrav);
> }
>
> }
>
> This prints the content of the txt-file to the console output.
> When uploading a different file, like a .exe or a .bin, the printf is
> making a error. This is OK because the content is not only text.
> How I have to write the uploaded content to a file? Just with
> CreateFile and WriteFile?
>
> What when I upload .exe or .bin files, do I have to read/write the
> content otherwise?
>
> Greetings
> Kniffel
Please look in the Microsoft Platform SDK for Windows Server 2003.
There are sample ISAPIs in there to illustrate how to correctly read
in a client upload. And yes, you have to CreateFile/WriteFile the
binary content after the ISAPI reads it off the socket from the
client.
Finally, Windows CE web server is not IIS, so its imitation of ISAPI
may not be 100% similar to real IIS ISAPI.
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//
Re: ISAPI file upload
am 11.09.2007 14:51:44 von David Wang
On Sep 11, 12:43 am, Kniffel wrote:
> > Please look in the Microsoft Platform SDK for Windows Server 2003.
> > There are sample ISAPIs in there to illustrate how to correctly read
> > in a client upload.
>
> Do you perhaps know which sample it is? There are a lot samples...
You only need the IIS related part of the SDK samples.
I forget the exact name, but search for a source file that has
"ReadClient" in it. It's a part of an entire library of useful ISAPI-
related functions, and that function shows how to read all entity from
the client no matter how they sent it.
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//