System.Web.HttpFileCollection allUploadedFiles =
System.Web.HttpContext.Current.Request.Files;
if (allUploadedFiles.Count == 0)
throw new Exception("No files uploaded");
if (allUploadedFiles.Count > 1)
throw new Exception("Too many files uploaded");
System.Web.HttpPostedFile uploadedFile = allUploadedFiles.Get(0);
String fileName = System.IO.Path.GetFileName(uploadedFile.FileName);
String fileExt = System.IO.Path.GetExtension(fileName);
if (fileExt.ToLower() != ".jpg")
throw new Exception("File is not a JPG image");
String newFileName = Server.MapPath("uploaded/images") + "\\" +
fileName;
if (System.IO.File.Exists(newFileName))
throw new Exception(fileName + " already exists, you must delete it
first");
uploadedFile.SaveAs(newFileName);
--
Pete
=============
http://www.DroopyEyes.com - Delphi source code
Audio compression components, Fast Strings, DIB Controls
Read or write article on just about anything
http://www.HowToDoThings.com
Dany said:
Hi,
I was wondering wether it was possible to upload files to a server using
only ASP (without external components, such as "AspSmartUpload") and te code
might look like.