FTP Upload Files to Web Server?

Question:
We are trying out the FTP2 ActiveX component for ASP. What we need to do is
have people be able to upload files to the web server over the Internet. Is
this component able to do this – or can it only FTP files that are already on the
web server?

Answer:
This is a common question. The need is to upload files from the user’s computer (i.e. the computer where the browser is running) to the web server. You should remember that your ASP code is running on the server (not on the computer where the browser is running). Therefore, any code within your ASP will only have access to the files on the web server. What you really want is to do a simple HTTP file upload from the browser. You’ll need to provide both client-side and server-side code to implement the HTTP upload. The client-side is extremely easy — you simply create a form with “file” type input tags:

<html>
<body>
<form method="POST" enctype="multipart/form-data" action = "http://www.mywebserver.com/ReceiveUpload.aspx" >
<input name=attach1 type=file size=20><br>
<input name=attach2 type=file size=20><br>
<input type=submit value="Upload">
</form>
</body>
</html>

The above form uploads two files, and also sends a few extra (non-file) form fields. To upload a single file, simply remove one of the “input” HTML tags.

Receiving the upload on the server-side requires programming.  It can be done in classic ASP, ASP.NET, Perl, a C++ CGI, etc.

Here are examples for classic ASP and ASP.NET:

Receive HTTP Upload Files in Classic ASP

Receive HTTP Uploads directly into memory in Classic ASP

Receive Upload + additional form fields in Classic ASP

Complete ASP.NET (C#) HTTP Upload Example