2009-09-24 7 views
-4

문제는 내가 lnkFV 링크 버튼을 클릭하면 이미지 URL을 설정합니다. 이미지는 페이지에 표시되지 않습니다.
소스업로드 이미지보기

<tr> 
    <td style="width: 160px; height: 15px"> 
     <asp:Label ID="Label4" runat="server" Text="Style Front View"> 
     </asp:Label> 
    </td> 
    <td style="width: 222px; height: 15px"> 
      <asp:FileUpload id="filFrontView" runat="server"> 
      </asp:FileUpload> 
    </td> 
    <td style="width: 72px; height: 15px"> 
      <asp:LinkButton id="lnkFV" runat="server" OnClick="lnkFV_Click"> 
      View image</asp:LinkButton> 
    </td> 
    <td colspan="3" rowspan="1"> 
     <asp:Image id="Image1" runat="server"> 
     </asp:Image></td> 
    </tr> 

ASP 코드

protected void lnkFV_Click(object sender, EventArgs e) 
{ 
    // new Help().Perform("Do you really want to proceed"); 
    try 
    { 
     file = Path.GetFileName(filFrontView.PostedFile.FileName); 
     // file = Path.GetFileName(filFrontView.PostedFile.FileName); 
     tempF = "F:\\Visual Studio 2005\\User\\temp\\" + file; 
     temp = "~\\temp\\" + file; 
     filFrontView.SaveAs(Server.MapPath(temp)); 
     // filFrontView.SaveAs(temp); 
     string filePath = MapPath(temp); 
     Image1.ImageUrl = tempF; 
    } 
    catch (Exception ee) 
    { 
    } 
} 
+1

무엇이 오류입니까? –

+0

이미지가 보이지 않습니다. – Suchinthaka

+0

ASP.NET Ajax를 사용하고 있습니까? 파일이 제대로 저장되고 있습니까? 예외가 있습니까? 더 자세한 정보가 필요합니다. –

답변

3

이 문제인가?

tempF = "F:\\Visual Studio 2005\\User\\temp\\" + file; 
// ... other stuff ... 
Image1.ImageUrl = tempF; 

당신이 이미지에 로컬 컴퓨터 경로의 문자열로 이미지 URL 속성을 설정하는 것 같습니다. 그것은 웹 서버에서 브라우저를 실행하지 않는 사람들에게는 효과가 없을 것입니다. ImageUrl은 현재 페이지 또는 웹 앱의 가상 루트를 기준으로 이미지의 상대 경로 여야합니다.

페이지가 최종적으로 렌더링 될 때 HTML 소스의 모습은 어떻습니까?

또한 웹에 액세스 할 수있는 폴더에 해당 이미지를 저장해야합니다. F:\Visual Studio 2005\User\temp 폴더가 실제로 청구서에 적합하지는 않을 것 같습니다. 일반적으로 사이트에서 웹 업로드 이미지를 볼 수있게하려면 경로를 하드 코딩하는 대신 상대 경로로 작업하고 싶을 것입니다.