최초등록
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,51 @@
|
||||
<%@ WebHandler Language="C#" Class="FileDragDrop.Web.FileUpload" %>
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.IO;
|
||||
|
||||
namespace FileDragDrop.Web
|
||||
{
|
||||
/// <summary>
|
||||
/// StoreFile의 요약 설명입니다.
|
||||
/// </summary>
|
||||
public class FileUpload : IHttpHandler
|
||||
{
|
||||
public void ProcessRequest(HttpContext context)
|
||||
{
|
||||
string check = context.Request["filestream"];
|
||||
check = Regex.Replace(check, " ", "+");
|
||||
byte[] bytes = Convert.FromBase64String(check);
|
||||
|
||||
string tempName = context.Request["filename"];
|
||||
string fileName = String.Format("{0}{1}", context.Server.MapPath("./Upload/"), HttpUtility.UrlDecode(tempName).TrimStart(' ')); //context.Server.MapPath(context.Request["filename"]);
|
||||
|
||||
string createDir = String.Format("{0}", context.Server.MapPath("./Upload")); // 경로
|
||||
DirectoryInfo di = new DirectoryInfo(createDir);
|
||||
if (!di.Exists)
|
||||
{
|
||||
di.Create();
|
||||
}
|
||||
|
||||
FileStream fs;
|
||||
|
||||
if (!File.Exists(fileName))
|
||||
fs = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write);
|
||||
else
|
||||
fs = new FileStream(fileName, FileMode.Append);
|
||||
fs.Write(bytes, 0, bytes.Length);
|
||||
fs.Close();
|
||||
fs.Dispose();
|
||||
}
|
||||
|
||||
public bool IsReusable
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 528 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
ASP.NET 응용 프로그램을 구성하는 방법에 대한 자세한 내용을 보려면
|
||||
http://go.microsoft.com/fwlink/?LinkId=169433 을 방문하십시오.
|
||||
-->
|
||||
<configuration>
|
||||
<system.web>
|
||||
<compilation debug="true"/>
|
||||
<customErrors mode="Off"/>
|
||||
<httpRuntime
|
||||
executionTimeout="90"
|
||||
maxRequestLength="512000"
|
||||
useFullyQualifiedRedirectUrl="false"
|
||||
minFreeThreads="8"
|
||||
minLocalRequestFreeThreads="4"
|
||||
appRequestQueueLimit="100"/>
|
||||
|
||||
</system.web>
|
||||
</configuration>
|
||||
@@ -0,0 +1,29 @@
|
||||
<%
|
||||
Sub createUpload()
|
||||
%>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var nn_basePath = "<%=nn_basePath%>";
|
||||
var nn_uploadPath = "<%=nn_uploadPath%>";
|
||||
var nn_paramMaxFileSize = "<%=nn_paramMaxFileSize%>";
|
||||
var nn_paramMaxFileNumber = "<%=nn_paramMaxFileNumber%>";
|
||||
var nn_paramFilter = "<%=nn_paramFilter%>";
|
||||
//]]>
|
||||
</script>
|
||||
<script type="text/javascript" src="<%=nn_basePath%>js/Silverlight.js"></script>
|
||||
<script type="text/javascript" src="<%=nn_basePath%>js/total.js"></script>
|
||||
<div id="silverlightControlHost">
|
||||
<object id="NnUpload" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="<%=nn_width%>" height="<%=nn_height%>">
|
||||
<param name="source" value="<%=nn_basePath%>ClientBin/FileDragDrop.xap"/>
|
||||
<param name="onError" value="onSilverlightError" />
|
||||
<param name="background" value="white" />
|
||||
<param name="onload" value="pluginLoaded" />
|
||||
<param name="minRuntimeVersion" value="5.0.61118.0" />
|
||||
<param name="autoUpgrade" value="true" />
|
||||
<param name="initParams" value="paramSerialKey=<%=nn_key%>,paramUrl=http://<%=Request.ServerVariables("HTTP_HOST") & nn_basePath%>/FileUpload.ashx, paramFilter=<%=nn_paramFilter%>, paramMaxFileSize=<%=(nn_paramMaxFileSize*1048576)%>, paramMaxFileNumber=<%=nn_paramMaxFileNumber%>, prarmControlWidth=700, paramControlHeight=400" />
|
||||
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0" style="text-decoration:none"><img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Microsoft Silverlight 얻기" style="border-style:none"/></a>
|
||||
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
|
||||
</div>
|
||||
<%
|
||||
End sub
|
||||
%>
|
||||
@@ -0,0 +1,58 @@
|
||||
<%@ codepage = 65001%>
|
||||
<% session.codepage = 65001 %>
|
||||
<%Response.CharSet = "UTF-8"%>
|
||||
<!--#include virtual="/content/board/nnupload/create.asp"-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" >
|
||||
<head runat="server">
|
||||
<title>FileDragDrop</title>
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<%
|
||||
'IIS에 추가할 mimetype
|
||||
'.xaml application/xaml+xaml
|
||||
'.xap application/x_silverlight-app
|
||||
'.xbap application/x-ms-xbap
|
||||
'.ashx ASP.NET HTTP Handler
|
||||
'nn_basePath 하위에 Upload 폴더와 nn_uploadPath에 지정될 폴더는 인터넷게스트계정는 또는 Users 계정에 수정/쓰기 권한이 있어야 합니다.
|
||||
|
||||
nn_basePath = "/content/board/nnupload/" 'nn업로드가 설치된 경로
|
||||
nn_paramFilter = "|.jpg|.zip|.txt|.xls" '업로드 허용 파일
|
||||
nn_paramMaxFileSize = 1 '업로드 용량(MB)
|
||||
nn_paramMaxFileNumber = 3 '업로드 개수
|
||||
nn_width = "500px" '가로크기
|
||||
nn_height = "300px" '세로크기
|
||||
nn_uploadPath = "/content/board/nnupload/Upload/" '업로드할 경로
|
||||
nn_key = "gt3E7pFzQLsb9+kqYldtGpLHjLZknptQjFgAcUXYCNwCgSlWXtXkPOIbmONi7swy" '키
|
||||
%>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var filenames = "";
|
||||
function getFileName(){ //업로드후 실제 업로드된 파일명을 배열로 반환
|
||||
filenames_arr = filenames.split("|");
|
||||
for(i=0;i<=filenames_arr.length-1;i++){
|
||||
alert(filenames_arr[i]);
|
||||
}
|
||||
filenames = "";
|
||||
|
||||
alert("업로드 완료");
|
||||
//Initialize(); //초기화
|
||||
}
|
||||
|
||||
function AbortUploadNotFile() {
|
||||
alert("업로드 할 파일 없습니다.");
|
||||
}
|
||||
|
||||
function UploadClick() {
|
||||
nnupload.content.UploadFile.StartUpload();
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<%
|
||||
createUpload() '업로드컨트롤 생성
|
||||
%>
|
||||
<input type="button" value="업로드" onclick="UploadClick()" />
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,75 @@
|
||||
<%@ codepage = 65001%>
|
||||
<% session.codepage = 65001 %>
|
||||
<%Response.CharSet = "UTF-8"%>
|
||||
<%
|
||||
Dim filename, filenames, path
|
||||
Dim org_path, trg_path
|
||||
Dim org_path_file, trg_path_file
|
||||
Dim fso
|
||||
|
||||
filenames = request.queryString( "filenames" )
|
||||
path = request.queryString( "path" )
|
||||
path = Replace(path,"/", "\")
|
||||
|
||||
org_path = server.mappath("./") & "\Upload\"
|
||||
trg_path = server.mappath("/") & path
|
||||
|
||||
filenames_arr = Split(filenames,"|")
|
||||
|
||||
Set fso = server.CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
For i = 0 To UBound(filenames_arr)
|
||||
org_path_file = org_path & filenames_arr(i)
|
||||
|
||||
If fso.FileExists( org_path_file ) Then
|
||||
|
||||
realfilename = getFileUniqName( trg_path, filenames_arr(i) ) '중복파일명 방지
|
||||
|
||||
If i > 0 Then realfilename_add = realfilename_add & "|"
|
||||
realfilename_add = realfilename_add & realfilename
|
||||
|
||||
trg_path_file = trg_path & realfilename
|
||||
fso.movefile org_path_file, trg_path_file
|
||||
|
||||
End If
|
||||
|
||||
next
|
||||
|
||||
Set fso = Nothing
|
||||
|
||||
response.write realfilename_add
|
||||
response.end
|
||||
|
||||
Function getFileUniqName(fullpath, filename)
|
||||
Dim j
|
||||
Dim count, bExist, strname, strext, filename_arr
|
||||
Dim fso
|
||||
Dim ret_filename
|
||||
|
||||
'파일명과 확장자 분리
|
||||
filename_arr = Split( filename, "." )
|
||||
strext = filename_arr( UBound(filename_arr) )
|
||||
strname = ""
|
||||
For j = 0 To UBound(filename_arr)-1
|
||||
strname = strname & filename_arr(j)
|
||||
Next
|
||||
|
||||
count= 0
|
||||
bExist = True
|
||||
ret_filename = filename
|
||||
|
||||
Set fso = server.CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
Do While bExist
|
||||
If (fso.FileExists(fullpath & ret_filename)) Then
|
||||
count = count + 1
|
||||
ret_filename = strname & "(" & count & ")." & strext
|
||||
Else
|
||||
Exit Do '없으며 빠져나간당..
|
||||
End If
|
||||
Loop
|
||||
|
||||
getFileUniqName = ret_filename
|
||||
|
||||
End function
|
||||
%>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,101 @@
|
||||
///////////// 사용자수정가능함수 ////////////
|
||||
|
||||
function AbortItemOver() {
|
||||
alert("허용 개수 "+nn_paramMaxFileNumber+"개를 초과했습니다.");
|
||||
}
|
||||
|
||||
function AbortSizeOver() {
|
||||
alert("허용 용량을 "+nn_paramMaxFileSize+"MB를 초과했습니다.");
|
||||
}
|
||||
|
||||
function AbortDeleteFile() {
|
||||
alert("삭제할 파일이 없습니다.");
|
||||
}
|
||||
|
||||
function AbortExtensionNot() {
|
||||
|
||||
alert("허용된 파일 형식이 아닙니다.\n\n허용파일: "+nn_paramFilter.replace(/\|/gi, " "));
|
||||
}
|
||||
|
||||
///////////// 사용자수정가능함수끝 ////////////
|
||||
|
||||
var nnupload = null;
|
||||
|
||||
function pluginLoaded(sender) {
|
||||
nnupload = document.getElementById("NnUpload");
|
||||
}
|
||||
|
||||
function NotifyUploadComplete() {
|
||||
fileMove(nn_uploadPath);
|
||||
}
|
||||
|
||||
function Initialize() {
|
||||
nnupload.content.UploadFile.Initialize();
|
||||
}
|
||||
|
||||
function fileMove(path){
|
||||
var file_names = "";
|
||||
var uploadFile = new Array();
|
||||
uploadFile = nnupload.content.UploadFile.UploadedFileName();
|
||||
|
||||
for(i=0;i<=uploadFile.length-1;i++){
|
||||
file_names = file_names + uploadFile[i] + "|";
|
||||
}
|
||||
|
||||
filenames = getHttpRequest(nn_basePath+"/filemove.asp?filenames="+escape(file_names)+"&path="+escape(path));
|
||||
getFileName();
|
||||
}
|
||||
|
||||
|
||||
function onSilverlightError(sender, args) {
|
||||
var appSource = "";
|
||||
if (sender != null && sender != 0) {
|
||||
appSource = sender.getHost().Source;
|
||||
}
|
||||
|
||||
var errorType = args.ErrorType;
|
||||
var iErrorCode = args.ErrorCode;
|
||||
|
||||
if (errorType == "ImageError" || errorType == "MediaError") {
|
||||
return;
|
||||
}
|
||||
|
||||
var errMsg = "Silverlight 응용 프로그램에서 처리되지 않은 오류 " + appSource + "\n" ;
|
||||
|
||||
errMsg += "코드: "+ iErrorCode + " \n";
|
||||
errMsg += "범주: " + errorType + " \n";
|
||||
errMsg += "메시지: " + args.ErrorMessage + " \n";
|
||||
|
||||
if (errorType == "ParserError") {
|
||||
errMsg += "파일: " + args.xamlFile + " \n";
|
||||
errMsg += "줄: " + args.lineNumber + " \n";
|
||||
errMsg += "위치: " + args.charPosition + " \n";
|
||||
}
|
||||
else if (errorType == "RumtimeError") {
|
||||
if (args.lineNumber != 0) {
|
||||
errMsg += "줄: " + args.lineNumber + " \n";
|
||||
errMsg += "위치: " + args.charPosition + " \n";
|
||||
}
|
||||
errMsg += "메서드 이름: " + args.methodName + " \n";
|
||||
}
|
||||
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
function getHttpRequest(url){
|
||||
var xmlhttp = null;
|
||||
if(window.XMLHttpRequest){
|
||||
xmlhttp = new XMLHttpRequest();
|
||||
}else{
|
||||
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
}
|
||||
xmlhttp.open("GET", url, false);
|
||||
xmlhttp.onreadystatechange = function(){
|
||||
if(xmlhttp.readyState == 4 && xmlhttp.status == 200 && xmlhttp.statusText == "OK"){
|
||||
responseText = xmlhttp.responseText;
|
||||
}
|
||||
}
|
||||
xmlhttp.send("");
|
||||
return responseText = xmlhttp.responseText;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user