Copying files with WebBatch
Keywords: webbatch copying files
Question:
I'd like to use WebBatch in my corporate intranet to copy files from a user's PC to a directory on my web server.Are there WebBatch functions to help me with this?
Answer:
Basically;
- You set up a file upload form to transfer the file from the user's machine to WebBatch.
- In WebBatch you use WebParamBuf to get the contents of the file into a binary buffer.
- Then you can use a BinaryWrite to write the BinaryBuffer to disk.
Question:
I was looking at this article and tried to utilize it to copy files over my intranet from a users machine to my Personal Web Server. In the steps that are outlined it states thatStep 1 in the article says to create a file upload form to pass the file from the user's machine to the WebBatch...(I think I have done this with the javascript fileupload object.)
Step 2 says to use the WebParamBuf command to get the contents of the file into a binary buffer. (When I do this I get the filename into the buffer and not the file contents itself.)
What am I doing wrong. Is the WebParamBuf only for form variables? How do I get the contents of the file into the WebParamBuf or is there another command? Thanks
Answer:
File uploads are quire tricky and only be done with multipart/form-data type encoding.I would suggest first making a simple HTML page using a form template like below.
Then make it work so you can upload a file.
Then go back to the method you are trying to use now.
<form enctype="multipart/form-data" method="post" action="/webcgi/webbatch.exe?yourscript.web"> <input type=file name="upl-file" size=80> <input type=text size=40 maxlength=40 name="desc"> <input type="radio" name="another" value="yes"> <input type="radio" name="another" value="no" checked> <input type=submit value="Upload Now"> </form>
Article ID: W12473Filename: Copy Files using Webbatch.txt