Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Upload a file while maintaining the original filename
;*************************************************************************** ;** ;** Upload.web - Bill Meek 071502 ;** ;** Purpose: Upload a file while maintaining the origional filename ;** Inputs: upload.htm ;** Outputs: A single file in the current folder ;** Revisions: ;*************************************************************************** mydir="C:\Program Files\WebBatch\upload\" DirChange(mydir) WebOut( 'Content-type: text/html', 2) WebOut( '<html> <head> <title>Upload Example</title> </head> <body>', 1) ;get the size of the file wfs=WebParamSize("upl-file") ;buffer to hold the file binbuf=BinaryAlloc(wfs) ;oversized buffer to hold the file with header info binbuf2=BinaryAlloc(wfs+5000) ;get the *unparsed* cotents of the form fields WebConBuf(binbuf2) startfn=BinaryIndexEx(binbuf2, 0, 'filename=', @FWDSCAN, @FALSE)+10 endfn=BinaryIndexEx(binbuf2, startfn, '"', @FWDSCAN, @FALSE) fullfilepath=BinaryPeekStr(binbuf2, startfn, endfn-startfn) filename=StrCat(FileRoot(fullfilepath),".",FileExtension(fullfilepath)) ;get the *parsed* cotents of the form field WebParamBuf("upl-file", binbuf) BinaryWrite(binbuf, filename) BinaryFree(binbuf2) BinaryFree(binbuf) WebOut( '</body>', 1) WebOut( '</html>', 1) ;Save the next part as Upload.web <form enctype="multipart/form-data" method="post" action="/webcgi/webbatch.exe?upload/upload.web"> <input type=file name="upl-file" size=80> <input type=submit value="Upload File"> </form>
Article ID: W15371
File Created: 2003:05:13:11:27:22
Last Updated: 2003:05:13:11:27:22