Picture of non-site directory and mapped network disk path-practical tips

Source: Internet
Author: User

This blog post teaches you how to display pictures in a non-site directory, you can display pictures of all the drive directories on the server where the site resides, and a picture that maps the network disk path. Here are two examples, one is to show the picture under D disk, another example is to show the Map network path picture.

Most practical in the enterprise, the occasional need for temporary display pictures, but users do not want to upload a large number of pictures, but placed on a workstation. So you need to map the path, or you can copy it directly to a certain drive on the server.

The following example shows a picture of a mapped network disk directory:

You can create a ashx file to work with pictures (core code):
Showoutsiteimage.ashx

Copy Code code as follows:

<%@ WebHandler language= "C #" class= "Insus.NET.ShowOutSiteImage"%>

Using System;
Using System.Web;
Using System.IO;

Namespace Insus.net
{
public class Showoutsiteimage:ihttphandler
{

public void ProcessRequest (HttpContext context)
{

String parameter = context. request.querystring["File"];

FileStream fs = new FileStream (parameter, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader (FS);
byte[] bytes = br. Readbytes ((Int32) fs. Length);
Br. Close ();
Fs. Close ();
Context. Response.OutputStream.Write (bytes, 0, bytes. Length);
}

public bool IsReusable
{
Get
{
return false;
}
}
}
}

When you need to display a picture, the following HTML "picture path" syntax, you can refer to the above two screenshots.
Copy Code code as follows:

<asp:image id= "Image1" runat= "Server" imageurl= "~/showoutsiteimage.ashx?file= picture path"/>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.