<input type="file" />
태그를 사용하여 파일을 서버에 업로드하고 있습니다. 서버 쪽에서 파일에 액세스하여 서버에 저장하려면 어떻게합니까?asp.net의 서버 쪽 입력 유형 파일에 액세스
클라이언트 측 코드입니다 (이 파일은 이미지 파일입니다) :
<form id="form1" action="PhotoStore.aspx" enctype="multipart/form-data">
<div>
<input type="file" id="file" onchange="preview(this)" />
<input type="submit" />
</div>
</form>
Photostore.aspx.cs 내가 JPG 파일을 업로드하려고
protected void Page_Load(object sender, EventArgs e)
{
int index = 1;
foreach (HttpPostedFile postedFile in Request.Files)
{
int contentLength = postedFile.ContentLength;
string contentType = postedFile.ContentType;
string fileName = postedFile.FileName;
postedFile.SaveAs(@"c:\test\file" + index + ".tmp");
index++;
}
}
있습니다. 저장된 파일을 볼 수 없습니다. 무슨 일 이니?
winforms 또는 mvc 또는 기타? –