티스토리 뷰
SmartEditor (스마트 에디터) - 이미지 파일 첨부 기능, 이미지 리사이즈 기능
Server] 이미지 첨부파일 Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Klattermusen.Models.File;
namespace Klattermusen.Admin.Controllers
{
public class SmartEditorController : Controller
{
protected override void Initialize(System.Web.Routing.RequestContext requestContext)
{
this.file = new File();
base.Initialize(requestContext);
}
[HttpGet]
public ActionResult ImageUpload()
{
return View();
}
[HttpPost]
public ActionResult ImageUpload(string filename, string renameFile, HttpPostedFileBase dataFieldName)
{
string fileFullPath = Server.MapPath(System.Web.Configuration.WebConfigurationManager.AppSettings["FileAttachedDynamicContents"]);
this.file.DirectoryMake(fileFullPath);
this.file.Save(dataFieldName, fileFullPath, renameFile + "_" + filename);
return View();
}
private IFile file;
}
}
Client] 이미지 첨부파일 View
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Image Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Imagetoolbar" content="no" />
<script type="text/javascript" src="<%= Url.Content("~/Scripts/jquery.js") %>"></script>
<script type="text/javascript" src="/Scripts/wyditor/NFUpload/nfupload.js?d=20081028"></script>
<script type="text/javascript">
<!--
function attachConfirm() {
document.getElementById('btnSubmit').style.display = "none";
document.getElementById('btnCancel').style.display = "none";
NfUpload.FileUpload();
}
function attachCancel() {
document.getElementById('btnSubmit').style.display = "";
document.getElementById('btnCancel').style.display = "";
Frm.reset();
}
function attachFinish(value) {
$(value.split('|')).each(function() {
opener.wyditorUploadOk('<%= Request["id"] %>', '<%= System.Web.Configuration.WebConfigurationManager.AppSettings["WebSite"] %>/<%= System.Web.Configuration.WebConfigurationManager.AppSettings["FileAttachedDynamicContents"] %>/' + this);
});
self.close();
}
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// -----------------------------------------------------------------------------
var _NF_MaxFileSize = 7168; // 업로드 제한 용량 (기본값: 10,240 Kb) (단위는 Kb)
var _NF_MaxFileCount = 10; // 업로드 파일 제한 갯수 (기본값: 10)
var _NF_UploadUrl = "/SmartEditor/ImageUpload"; // 업로드 소스파일 경로 (반드시 입력해야함)
var _NF_FileFilter = "이미지(*.jpg,*.gif,*.png,*.bmp,*.swf)|:|*.jpg;*.gif;*.png;*.bmp;*.swf"; // 파일 필터링 값 ("이미지(*.jpg)|:|*.jpg;*.gif;*.png;*.bmp"); // 기본값 모든파일
var _NF_DataFieldName = "DataFieldName"; // 업로드 폼에 사용되는 값 (기본값(UploadData))
var _NF_Flash_Url = "/Scripts/wyditor/NFUpload/nfupload.swf?d=20081028"; // 업로드 컴포넌트 플래쉬 파일명
var _NF_File_Overwrite = false; // 업로드시 파일명 처리방법(true : 원본파일명 유지, 덮어씌우기 모드 / false : 유니크파일명으로 변환, 중복방지)
var _NF_Limit_Ext = "asp;html;htm;php;php3;cgi;phtm;phtm;inc;sql;pl"; // 파일 제한 확장자
// 플래시 업로더 화면 구성 설정 변수
var _NF_Width = 450; // 업로드 컴포넌트 넓이 (기본값 480)
var _NF_Height = 181; // 업로드 컴포넌트 폭 (기본값 150)
var _NF_ColumnHeader1 = "파일명"; // 컴포넌트에 출력되는 파일명 제목 (기본값: File Name)
var _NF_ColumnHeader2 = "용량"; // 컴포넌트에 출력되는 용량 제목 (기본값: File Size)
var _NF_FontFamily = "굴림"; // 컴포넌트에서 사용되는 폰트 (기본값: Times New Roman)
var _NF_FontSize = "11"; // 컴포넌트에서 사용되는 폰트 크기 (기본값: 11)
// [2008-10-28] Flash 10 support
var _NF_Img_FileBrowse = "/Scripts/wyditor/NFUpload/images/btn_file_browse.gif"; // 파일찾기 이미지
var _NF_Img_FileBrowse_Width = "59"; // 파일찾기 이미지 넓이 (기본값 59)
var _NF_Img_FileBrowse_Height = "22"; // 파일찾기 이미지 폭 (기본값 22)
var _NF_Img_FileDelete = "/Scripts/wyditor/NFUpload/images/btn_file_delete.gif"; // 파일삭제 이미지
var _NF_Img_FileDelete_Width = "59"; // 파일삭제 이미지 넓이 (기본값 59)
var _NF_Img_FileDelete_Height = "22"; // 파일삭제 이미지 폭 (기본값 22)
var _NF_TotalSize_Text = "전체용량 "; // 파일용량 텍스트
var _NF_TotalSize_FontFamily = "굴림"; // 파일용량 텍스트 폰트
var _NF_TotalSize_FontSize = "11"; // 파일용량 텍스트 폰트 크기
var frmUpload;
window.onload = function() {
// [2008-10-28] Flash 10 support
//sMaxSize.innerHTML = SizeCalc(_NF_MaxFileSize);
}
/*****************************************************************************
/* 업로드가 완료 되었을 때 사용되는 함수
/* (주의: 이 함수명은 변경하면 안됩니다.)
/*
/* 함수명을 변경하게 되면 업로드가 완료된 다음 다른 작업을 진행할 수 없습니다.
/* value: 파일명들 (배열로 리턴됨. 단, 업로드가 진행되지 않으면 null값 리턴)
/*****************************************************************************/
function NFU_Complete(value) {
var files = "";
var fileCount = 0;
var i = 0;
// 이 부분을 수정해서 파일이 선택되지 않았을 때에도 submit을 하게 수정할 수 있습니다.
if (value == null) {
alert("업로드할 파일을 선택해 주세요.");
return;
}
fileCount = value.length;
for (i = 0; i < fileCount; i++) {
var fileName = value[i].name;
var realName = value[i].realName;
var fileSize = value[i].size;
files += ((files) ? "|" : "") + fileName + "_" + realName;
}
attachFinish(files);
}
/******************************************************************************
/* 파일 선택한 뒤 용량을 반환해 주는 함수
/* (주의: 이 함수명은 변경하면 안됩니다.)
/*
/* 함수명을 변경하게 되면 업로드가 완료된 다음 다른 작업을 진행할 수 없습니다.
/* value: 선택한 파일 용량 (용량은 KB, MB, GB 단위)
/*****************************************************************************/
function NF_ShowUploadSize(value) {
// value값에 실제 업로드된 용량이 넘어온다.
document.getElementById("sUploadSize").innerHTML = value;
}
function NFUpload_Debug(value) {
Debug("업로드 오류!!!\r\n\r\n" + value);
}
function Cancel() {
// 초기화 할때는 첨부파일 리스트도 같이 초기화 시켜 준다.
NfUpload.AllFileDelete();
attachCancel();
}
// -->
</script>
</head>
<body bgcolor="#FFFFFF">
<form name="Frm" method="post">
<input type="hidden" name="mode" value="img">
<input type="hidden" name="id" value="content">
<input type="hidden" name="path" value="/data/rental/editor/201501">
<input type="hidden" name="attach">
</form>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="5"><img src="/scripts/wyditor/images/up_title_bg1.gif" width="5" height="30"></td>
<td bgcolor="#44B4B3" style="padding-left:15px;"><strong><font color="#FFFFFF">이미지 업로드</font></strong></td>
<td width="5"><img src="/scripts/wyditor/images/up_title_bg2.gif" width="5" height="30"></td>
</tr>
</table>
</td>
</tr>
<tr><td height="8"></td></tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="5"><img src="/scripts/wyditor/images/up_top_left.gif" width="5" height="5"></td>
<td background="/scripts/wyditor/images/up_top.gif"></td>
<td width="5"><img src="/scripts/wyditor/images/up_top_right.gif" width="5" height="5"></td>
</tr>
<tr>
<td background="/scripts/wyditor/images/up_left.gif"></td>
<td style="padding:10px;">
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center" colspan="2" style="padding:3px 0 3px 0">
<script language="javascript">
<!--
// Flash 업로더 객체를 생성하는 자바 스크립트 입니다.
// 이 스크립트는 Form 태그내에 들어가게 되면 오류가 발생하기 때문에
// 반드시 Form 태그 밖에서 사용해야 합니다.
// [2008-10-28] Flash 10 support
NfUpload = new NFUpload({
nf_upload_id: _NF_Uploader_Id,
nf_width: _NF_Width,
nf_height: _NF_Height,
nf_field_name1: _NF_ColumnHeader1,
nf_field_name2: _NF_ColumnHeader2,
nf_max_file_size: _NF_MaxFileSize,
nf_max_file_count: _NF_MaxFileCount,
nf_upload_url: _NF_UploadUrl,
nf_file_filter: _NF_FileFilter,
nf_data_field_name: _NF_DataFieldName,
nf_font_family: _NF_FontFamily,
nf_font_size: _NF_FontSize,
nf_flash_url: _NF_Flash_Url,
nf_file_overwrite: _NF_File_Overwrite,
nf_limit_ext: _NF_Limit_Ext,
nf_img_file_browse: _NF_Img_FileBrowse,
nf_img_file_browse_width: _NF_Img_FileBrowse_Width,
nf_img_file_browse_height: _NF_Img_FileBrowse_Height,
nf_img_file_delete: _NF_Img_FileDelete,
nf_img_file_delete_width: _NF_Img_FileDelete_Width,
nf_img_file_delete_height: _NF_Img_FileDelete_Height,
nf_total_size_text: _NF_TotalSize_Text,
nf_total_size_font_family: _NF_TotalSize_FontFamily,
nf_total_size_font_size: _NF_TotalSize_FontSize
});
//-->
</script>
</td>
</tr>
<tr height="26">
<td align="center" colspan="2" style="padding-top:5px;"><img id="btnSubmit" src="/scripts/wyditor/images/bt_confirm.gif" width="47" height="21" hspace="4" border="0" onClick="attachConfirm()" style="cursor:pointer;"><img id="btnCancel" src="/scripts/wyditor/images/bt_cancel.gif" width="47" height="21" hspace="4" border="0" onClick="self.close()" style="cursor:pointer;"></td>
</tr>
</table>
</td>
<td background="/scripts/wyditor/images/up_right.gif"></td>
</tr>
<tr>
<td><img src="/scripts/wyditor/images/up_bottom_left.gif" width="5" height="5"></td>
<td background="/scripts/wyditor/images/up_bottom.gif"></td>
<td><img src="/scripts/wyditor/images/up_bottom_right.gif" width="5" height="5"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Client] SmartEditor 생성 View
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/WebSite.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Create
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Dynamic Contents Create</h2>
<% Html.BeginForm("Create", "DynamicContentsManager", FormMethod.Post); %>
<%= Html.TextArea("Contents", null, new { @style = "width:750px; height:360px;" }) %>
<br />
<input type="submit" value="저장" />
<% Html.EndForm(); %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">
<script type="text/javascript" src="<%= Url.Content("~/Scripts/wyditor/wyditor.js")%>"></script>
<script type="text/javascript">
$(document).ready(function() {
var objEditor = new wyditor('Contents');
objEditor.create();
});
</script>
</asp:Content>
- Total
- Today
- Yesterday
- System.Diagnostics
- java-개발 환경 설정하기
- error-java
- 표현 언어(expression language)
- nl2br
- 스프링 시큐리티(spring security)-http basic 인증
- 스프링 프레임워크(spring framework)
- MainActor
- 람다식(lambda expression)
- docker
- 특정 문자를 기준으로 자르기
- React
- java 키워드 정리
- 진수 변환
- 문자 자르기
- system.io
- 스프링 시큐리티(spring security)
- jstl(java standard tag library)
- REST API
- .submit()
- 스프링 프레임워크(spring framewordk)
- In App Purchase
- 제품 등록
- java.sql
- jstl(java standard tag library)-core
- await
- 인텔리제이(intellij)
- java web-mvc
- jsp 오픈 소스
- 메이븐(maven)
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |