ASP.NET MVC로 작성된 파일 업로드 프로그램이 있습니다. 현재 로컬 개발 컴퓨터에 있습니다. 업로드 한 각 파일에 대한 링크를 생성하는 방법 (가능한 경우)을 클릭하여 항목을 표시/다운로드하는 방법을 알고 싶습니다.로컬 파일의 경로 경로 ASP.NET/MVC
현재 코드/파일 목록을 표시 핸들 태그 :
<table>
<tr>
<th></th>
<th>
Name
</th>
<th>
Length
</th>
<th></th>
</tr>
<%
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "uploads");
foreach (var file in Directory.GetFiles(path))
{
var item = new FileInfo(file);
%>
<tr>
<td></td>
<td>
<%=Html.Encode(Path.GetFileName(item.Name))%>
</td>
<td>
<%=Html.Encode(item.Length >= 1024 ? item.Length/1024 + " kilobytes" : item.Length + " bytes")%>
</td>
<td>
// This is the line in question. Does not work as-is.
<a href="<%= item.FullName %>"><%= Html.Encode(Path.GetFileName(item.Name)) %></a>
</td>
</tr>
<% } %>
</table>
을 나는이 온라인 상태가 된 후에 주위의 파일 처리 코드를 변경해야합니다 상상,하지만 지금은이 충분하다. 제안도 환영합니다 :)
고마워!
+1 (MVC3 - elmah.axd에 연결) 감사합니다! – ashes999