14.3. Displaying Uploaded Image Files As Thumbnails

Sharing files is one of the most popular pastimes on the Internet. Participants in a Web site upload pictures and videos for others to view. In this section, you create a small ASP.NET application that uploads a large image to the Web server and then immediately displays a thumbnail version of the image. In the following sections, you see that ASP.NET and the .NET Framework do most of the work. Your job is to assemble and organize the work crew.

14.3.1. Accepting a file upload

The goal in this section is to let a visitor upload an image file and store the image on the Web server. The code is picky about what it accepts: The file must have a .gif or .jpg extension. Anything else generates a warning.

Allowing uploads of any kind to a Web server requires you to give the user or the ASP.NET account write access to the file system on the Web server. Write access weakens security, so check with your administrator to be sure you're not creating vulnerabilities.

To create a page that uploads images, follow these steps:

  1. Make sure that your project has an images folder.

  2. Add an ASP.NET page named upld.aspx to your project (FileNew FileWeb Form) ...

Get ASP.NET 3.5 For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.