티스토리 뷰
public Hashtable attachFileUpload(System.Web.UI.WebControls.FileUpload fileUploadControl)
{
Hashtable result = new Hashtable();
string dateString = DateTime.Now.ToShortDateString();
string savePath = WebConfigurationManager.AppSettings["attachFileHome"].ToString() + dateString + "\\";
makeFoler(savePath);
int fileSize = fileUploadControl.PostedFile.ContentLength;
string fileName = HttpUtility.HtmlEncode(fileUploadControl.FileName);
string tempFileName = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + Path.GetExtension(fileName);
string DB_fileName = dateString + "\\" + fileName;
string DB_tempFileName = dateString + "\\" + tempFileName;
string fileNameExtension = System.IO.Path.GetExtension(fileName);
//4,200,000 bytes(4MB)
if ((fileSize < 4200000) && (fileNameExtension.ToLower().Equals(".jpg") || fileNameExtension.ToLower().Equals(".gif")))
{
savePath += tempFileName;
fileUploadControl.SaveAs(savePath);
result.Add(DB_fileName, DB_tempFileName);
}
return result;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (IsPostBack)
{
Boolean fileOK = false;
String path = Server.MapPath("~/UploadedImages/");
if (FileUpload1.HasFile)
{
String fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
for (int i = 0; i < allowedExtensions.Length; i++)
{
if (fileExtension == allowedExtensions[i])
{
fileOK = true;
break;
}
}
}
if (fileOK)
{
try
{
FileUpload1.PostedFile.SaveAs(path+ FileUpload1.FileName);
Label1.Text = String.Format("File uploaded!({0:#,###0}/Byte)", FileUpload1.PostedFile.ContentLength);
}
catch (Exception ex)
{
Label1.Text = "File could not be uploaded.";
}
}
else
{
Label1.Text = "Cannot accept files of this type.";
}
}
}
- Total
- Today
- Yesterday
- 특정 문자를 기준으로 자르기
- java.sql
- docker
- 인텔리제이(intellij)
- jstl(java standard tag library)
- jstl(java standard tag library)-core
- 문자 자르기
- jsp 오픈 소스
- 스프링 시큐리티(spring security)-http basic 인증
- 스프링 프레임워크(spring framework)
- 람다식(lambda expression)
- 스프링 프레임워크(spring framewordk)
- java web-mvc
- system.io
- In App Purchase
- 제품 등록
- java 키워드 정리
- nl2br
- await
- 스프링 시큐리티(spring security)
- System.Diagnostics
- 진수 변환
- 표현 언어(expression language)
- REST API
- error-java
- 메이븐(maven)
- MainActor
- java-개발 환경 설정하기
- .submit()
- React
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |