글
string UpLoadPath = "~/File/"; // 업로드 폴더의 웹경로
string fileName = string.Empty;
if (txtFile.PostedFile != null)
{
fileName = Path.GetFileName(txtFile.FileName);
string tmpFileName = fileName;
string savePath = Server.MapPath(UpLoadPath + tmpFileName);
int j = 0;
while (File.Exists(savePath)) //파일중복체크
{
j++;
tmpFileName = Path.GetFileNameWithoutExtension(fileName) + "(" + j.ToString() + ")" + Path.GetExtension(fileName);
savePath = Server.MapPath( UpLoadPath + tmpFileName );
}
string fname = txtFile.FileName;
if (fname != "") // 사진을 등록하지 않고 회원가입할때 파일업로드 입력박스 null 체크
{
txtFile.PostedFile.SaveAs(savePath);
}
fileName = tmpFileName;
}
string fileName = string.Empty;
if (txtFile.PostedFile != null)
{
fileName = Path.GetFileName(txtFile.FileName);
string tmpFileName = fileName;
string savePath = Server.MapPath(UpLoadPath + tmpFileName);
int j = 0;
while (File.Exists(savePath)) //파일중복체크
{
j++;
tmpFileName = Path.GetFileNameWithoutExtension(fileName) + "(" + j.ToString() + ")" + Path.GetExtension(fileName);
savePath = Server.MapPath( UpLoadPath + tmpFileName );
}
string fname = txtFile.FileName;
if (fname != "") // 사진을 등록하지 않고 회원가입할때 파일업로드 입력박스 null 체크
{
txtFile.PostedFile.SaveAs(savePath);
}
fileName = tmpFileName;
}
'ASP.NET' 카테고리의 다른 글
| 게시판 리스트에 코멘트 출력 메소드 (0) | 2007/06/29 |
|---|---|
| 게시판 [이전글] / [다음글] 만들기 (0) | 2007/06/29 |
| 최근 24시간 동안 새로 올라온 글이 new 이미지 표시메소드 (0) | 2007/06/29 |
| 파일 업로드 (0) | 2007/06/28 |
