|
We create an Upload object and specify some variables. We'll be
using one ABCUpload UploadedFile object and one ASP.NET
HttpPostedFile object to show how we can use both at the same time.
We could reduce the amount of code considerably if we made use of
ABCUpload added functionality but the aim for this example is to
show how both objects can be used identically.
First we get a reference to our file object by referencing the
Files collection within the Upload object. We check that some data
has been uploaded and if so we work out a destination file name and
then save the file to this location. The code using the standard
ASP.NET classes is identical.
<%@ Import
Namespace="WebSupergoo.ABCUpload6" %>
<%
Upload Upload = new Upload();
UploadedFile theFile1;
HttpPostedFile theFile2;
string thePath;
theFile1 = Upload.Files["image1"];
if (theFile1.ContentLength > 0) {
thePath =
System.IO.Path.GetFileName(theFile1.FileName);
thePath = Server.MapPath("write/") + thePath;
theFile1.SaveAs(thePath);
}
theFile2 = Request.Files["image2"];
if (theFile2.ContentLength > 0) {
thePath =
System.IO.Path.GetFileName(theFile2.FileName);
thePath = Server.MapPath("write/") + thePath;
theFile2.SaveAs(thePath);
}
%>
<html>
<body>
Images uploaded...
</body>
</html>
<%@ Import
Namespace="WebSupergoo.ABCUpload6" %>
<%
Dim Upload As Upload = New Upload()
Dim theFile1 As UploadedFile
Dim theFile2 As HttpPostedFile
Dim thePath As String
theFile1 = Upload.Files("image1")
If theFile1.ContentLength > 0 Then
thePath =
System.IO.Path.GetFileName(theFile1.FileName)
thePath = Server.MapPath("write/") + thePath
theFile1.SaveAs(thePath)
End If
theFile2 = Request.Files("image2")
If theFile2.ContentLength > 0 Then
thePath =
System.IO.Path.GetFileName(theFile2.FileName)
thePath = Server.MapPath("write/") + thePath
theFile2.SaveAs(thePath)
End If
%>
<html>
<body>
Images uploaded...
</body>
</html>
|