2011-12-26 33 views
0

「C:\ Uploader \ Image.jpg」のような画像パスやサーバーの共有フォルダの画像は表示されません。私のプロジェクト内のパスを与えても、そのプロジェクトの外では(C:\ Uploader \ Image.jpgのように)何も表示されません。ここで私はdatabind.Whatを使用して動的にパスを添付しています画像が「C: Uploader Image.jpg」のような画像パスで表示されないadrotatorに画像が表示されない

<telerik:RadRotator ID="radSlider" runat="server" FrameDuration="400" ScrollDuration="500" 
ScrollDirection="Left" Height="250px" Width="550px"> 
<ItemTemplate> 
    <img src='<%# Eval("FullName") %>' alt="Friday" width="550px" /> 
</ItemTemplate> 
</telerik:RadRotator> 

はproblem.Plzが私を助けているのですか?TelerikまたはASP制御

答えて

1

仮想ディレクトリをイメージにマップしない限り、クライアントブラウザはイメージの場所を決して知りません。ドライブをマップするのにServer.MapPath()などを使用することはできません。

アプリケーション仮想ディレクトリ以外のファイルにアクセスするには、HttpHandlerを使用する必要があります。
Show Images from outside of ASP.NET Application

私は次のようにこれについてゴーグル後に得ているもう一つのアプローチ:

をあなたがファイルにアクセスしようとすることができるので、多くの関連問題へのスレッド次

チェック外部アプリケーションの仮想ディレクトリ。十分な許可をフォルダ/ファイルに注意する必要があります。あなたのウェブサイト内の画像にアクセスするための

次のことができ、あなたは次のリンクをチェックすることができます

Displaying images that are stored outside the Website Root Folder

protected void Page_Load(object sender, EventArgs e) 

{ 

if (Request.QueryString["FileName"] != null) 

{ 

    try 

    { 

     // Read the file and convert it to Byte Array 

     string filePath = "C:\\images\\"; 

     string filename = Request.QueryString["FileName"]; 

     string contenttype = "image/" + 

     Path.GetExtension(Request.QueryString["FileName"].Replace(".",""); 

     FileStream fs = new FileStream(filePath + filename, 

     FileMode.Open, FileAccess.Read); 

     BinaryReader br = new BinaryReader(fs); 

     Byte[] bytes = br.ReadBytes((Int32)fs.Length); 

     br.Close(); 

     fs.Close(); 



     //Write the file to response Stream 

     Response.Buffer = true; 

     Response.Charset = ""; 

     Response.Cache.SetCacheability(HttpCacheability.NoCache); 

     Response.ContentType = contenttype; 

     Response.AddHeader("content-disposition", "attachment;filename=" + filename); 

     Response.BinaryWrite(bytes); 

     Response.Flush(); 

     Response.End(); 

    } 

    catch 

    { 

    } 

} 

} 

・ホープこのヘルプを。

+0

Thak you so much ..... –

0

あなたは別の場所にファイルを提供するためにIHTTPハンドラを使用する必要があります(例:外アプリケーションルートまたは特権フォルダにあります)。 AFAIK、Telerik Rad ControlsにはRadBinaryImageなどがあります。

関連する問題