migrate to new git
This commit is contained in:
BIN
web/App_Script/swfupload/FC2Column.swf
Normal file
BIN
web/App_Script/swfupload/FC2Column.swf
Normal file
Binary file not shown.
BIN
web/App_Script/swfupload/FC2Pie3D.swf
Normal file
BIN
web/App_Script/swfupload/FC2Pie3D.swf
Normal file
Binary file not shown.
281
web/App_Script/swfupload/handlers.js
Normal file
281
web/App_Script/swfupload/handlers.js
Normal file
@@ -0,0 +1,281 @@
|
||||
function fileQueueError(file, errorCode, message) {
|
||||
try {
|
||||
var imageName = "error.gif";
|
||||
var errorName = "";
|
||||
if (errorCode === SWFUpload.errorCode_QUEUE_LIMIT_EXCEEDED) {
|
||||
errorName = "您上傳太多的圖片";
|
||||
}
|
||||
|
||||
if (errorName !== "") {
|
||||
alert(errorName);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (errorCode) {
|
||||
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
|
||||
imageName = "zerobyte.gif";
|
||||
break;
|
||||
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
|
||||
imageName = "toobig.gif";
|
||||
break;
|
||||
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
|
||||
case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
|
||||
default:
|
||||
alert(message);
|
||||
break;
|
||||
}
|
||||
|
||||
addImage("../../App_Script/swfupload/images/" + imageName);
|
||||
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function fileDialogComplete(numFilesSelected, numFilesQueued) {
|
||||
try {
|
||||
if (numFilesQueued > 0) {
|
||||
this.startUpload();
|
||||
}
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadProgress(file, bytesLoaded) {
|
||||
|
||||
try {
|
||||
var percent = Math.ceil((bytesLoaded / file.size) * 100);
|
||||
|
||||
var progress = new FileProgress(file, this.customSettings.upload_target);
|
||||
progress.setProgress(percent);
|
||||
if (percent === 100) {
|
||||
progress.setStatus("Creating thumbnail...");
|
||||
progress.toggleCancel(false, this);
|
||||
} else {
|
||||
progress.setStatus("上傳中,請稍候...");
|
||||
progress.toggleCancel(true, this);
|
||||
}
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadSuccess(file, serverData) {
|
||||
try {
|
||||
//addImage("ShowThumbnail.aspx?id=" + serverData);
|
||||
|
||||
var progress = new FileProgress(file, this.customSettings.upload_target);
|
||||
|
||||
progress.setStatus("Thumbnail Created.");
|
||||
progress.toggleCancel(false);
|
||||
|
||||
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadComplete(file) {
|
||||
try {
|
||||
/* I want the next upload to continue automatically so I'll call startUpload here */
|
||||
if (this.getStats().files_queued > 0) {
|
||||
this.startUpload();
|
||||
} else {
|
||||
var progress = new FileProgress(file, this.customSettings.upload_target);
|
||||
progress.setComplete();
|
||||
progress.setStatus("您所選擇的圖片皆已上傳");
|
||||
progress.toggleCancel(false);
|
||||
}
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadError(file, errorCode, message) {
|
||||
var imageName = "error.gif";
|
||||
var progress;
|
||||
try {
|
||||
switch (errorCode) {
|
||||
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
|
||||
try {
|
||||
progress = new FileProgress(file, this.customSettings.upload_target);
|
||||
progress.setCancelled();
|
||||
progress.setStatus("Cancelled");
|
||||
progress.toggleCancel(false);
|
||||
}
|
||||
catch (ex1) {
|
||||
this.debug(ex1);
|
||||
}
|
||||
break;
|
||||
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
|
||||
try {
|
||||
progress = new FileProgress(file, this.customSettings.upload_target);
|
||||
progress.setCancelled();
|
||||
progress.setStatus("Stopped");
|
||||
progress.toggleCancel(true);
|
||||
}
|
||||
catch (ex2) {
|
||||
this.debug(ex2);
|
||||
}
|
||||
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
|
||||
imageName = "uploadlimit.gif";
|
||||
break;
|
||||
default:
|
||||
alert(message);
|
||||
break;
|
||||
}
|
||||
|
||||
addImage("../../App_Script/swfupload/images/" + imageName);
|
||||
|
||||
} catch (ex3) {
|
||||
this.debug(ex3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function addImage(src) {
|
||||
var newImg = document.createElement("img");
|
||||
newImg.style.margin = "5px";
|
||||
|
||||
document.getElementById("thumbnails").appendChild(newImg);
|
||||
if (newImg.filters) {
|
||||
try {
|
||||
newImg.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 0;
|
||||
} catch (e) {
|
||||
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
|
||||
newImg.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + 0 + ')';
|
||||
}
|
||||
} else {
|
||||
newImg.style.opacity = 0;
|
||||
}
|
||||
|
||||
newImg.onload = function () {
|
||||
fadeIn(newImg, 0);
|
||||
};
|
||||
newImg.src = src;
|
||||
}
|
||||
|
||||
function fadeIn(element, opacity) {
|
||||
var reduceOpacityBy = 5;
|
||||
var rate = 30; // 15 fps
|
||||
|
||||
|
||||
if (opacity < 100) {
|
||||
opacity += reduceOpacityBy;
|
||||
if (opacity > 100) {
|
||||
opacity = 100;
|
||||
}
|
||||
|
||||
if (element.filters) {
|
||||
try {
|
||||
element.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity;
|
||||
} catch (e) {
|
||||
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
|
||||
element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')';
|
||||
}
|
||||
} else {
|
||||
element.style.opacity = opacity / 100;
|
||||
}
|
||||
}
|
||||
|
||||
if (opacity < 100) {
|
||||
setTimeout(function () {
|
||||
fadeIn(element, opacity);
|
||||
}, rate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ******************************************
|
||||
* FileProgress Object
|
||||
* Control object for displaying file info
|
||||
* ****************************************** */
|
||||
|
||||
function FileProgress(file, targetID) {
|
||||
this.fileProgressID = "divFileProgress";
|
||||
|
||||
this.fileProgressWrapper = document.getElementById(this.fileProgressID);
|
||||
if (!this.fileProgressWrapper) {
|
||||
this.fileProgressWrapper = document.createElement("div");
|
||||
this.fileProgressWrapper.className = "progressWrapper";
|
||||
this.fileProgressWrapper.id = this.fileProgressID;
|
||||
|
||||
this.fileProgressElement = document.createElement("div");
|
||||
this.fileProgressElement.className = "progressContainer";
|
||||
|
||||
var progressCancel = document.createElement("a");
|
||||
progressCancel.className = "progressCancel";
|
||||
progressCancel.href = "#";
|
||||
progressCancel.style.visibility = "hidden";
|
||||
progressCancel.appendChild(document.createTextNode(" "));
|
||||
|
||||
var progressText = document.createElement("div");
|
||||
progressText.className = "progressName";
|
||||
progressText.appendChild(document.createTextNode(file.name));
|
||||
|
||||
var progressBar = document.createElement("div");
|
||||
progressBar.className = "progressBarInProgress";
|
||||
|
||||
var progressStatus = document.createElement("div");
|
||||
progressStatus.className = "progressBarStatus";
|
||||
progressStatus.innerHTML = " ";
|
||||
|
||||
this.fileProgressElement.appendChild(progressCancel);
|
||||
this.fileProgressElement.appendChild(progressText);
|
||||
this.fileProgressElement.appendChild(progressStatus);
|
||||
this.fileProgressElement.appendChild(progressBar);
|
||||
|
||||
this.fileProgressWrapper.appendChild(this.fileProgressElement);
|
||||
|
||||
document.getElementById(targetID).appendChild(this.fileProgressWrapper);
|
||||
fadeIn(this.fileProgressWrapper, 0);
|
||||
|
||||
} else {
|
||||
this.fileProgressElement = this.fileProgressWrapper.firstChild;
|
||||
this.fileProgressElement.childNodes[1].firstChild.nodeValue = file.name;
|
||||
}
|
||||
|
||||
this.height = this.fileProgressWrapper.offsetHeight;
|
||||
|
||||
}
|
||||
FileProgress.prototype.setProgress = function (percentage) {
|
||||
this.fileProgressElement.className = "progressContainer green";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
|
||||
this.fileProgressElement.childNodes[3].style.width = percentage + "%";
|
||||
};
|
||||
FileProgress.prototype.setComplete = function () {
|
||||
this.fileProgressElement.className = "progressContainer blue";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarComplete";
|
||||
this.fileProgressElement.childNodes[3].style.width = "";
|
||||
|
||||
};
|
||||
FileProgress.prototype.setError = function () {
|
||||
this.fileProgressElement.className = "progressContainer red";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarError";
|
||||
this.fileProgressElement.childNodes[3].style.width = "";
|
||||
|
||||
};
|
||||
FileProgress.prototype.setCancelled = function () {
|
||||
this.fileProgressElement.className = "progressContainer";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarError";
|
||||
this.fileProgressElement.childNodes[3].style.width = "";
|
||||
|
||||
};
|
||||
FileProgress.prototype.setStatus = function (status) {
|
||||
this.fileProgressElement.childNodes[2].innerHTML = status;
|
||||
};
|
||||
|
||||
FileProgress.prototype.toggleCancel = function (show, swfuploadInstance) {
|
||||
this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";
|
||||
if (swfuploadInstance) {
|
||||
var fileID = this.fileProgressID;
|
||||
this.fileProgressElement.childNodes[0].onclick = function () {
|
||||
swfuploadInstance.cancelUpload(fileID);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
};
|
||||
281
web/App_Script/swfupload/handlers2.js
Normal file
281
web/App_Script/swfupload/handlers2.js
Normal file
@@ -0,0 +1,281 @@
|
||||
function fileQueueError(file, errorCode, message) {
|
||||
try {
|
||||
var imageName = "error.gif";
|
||||
var errorName = "";
|
||||
if (errorCode === SWFUpload.errorCode_QUEUE_LIMIT_EXCEEDED) {
|
||||
errorName = "您上傳太多的檔案";
|
||||
}
|
||||
|
||||
if (errorName !== "") {
|
||||
alert(errorName);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (errorCode) {
|
||||
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
|
||||
imageName = "zerobyte.gif";
|
||||
break;
|
||||
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
|
||||
imageName = "toobig.gif";
|
||||
break;
|
||||
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
|
||||
case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
|
||||
default:
|
||||
alert(message);
|
||||
break;
|
||||
}
|
||||
|
||||
addImage("../../App_Script/swfupload/images/" + imageName);
|
||||
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function fileDialogComplete(numFilesSelected, numFilesQueued) {
|
||||
try {
|
||||
if (numFilesQueued > 0) {
|
||||
this.startUpload();
|
||||
}
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadProgress(file, bytesLoaded) {
|
||||
|
||||
try {
|
||||
var percent = Math.ceil((bytesLoaded / file.size) * 100);
|
||||
|
||||
var progress = new FileProgress(file, this.customSettings.upload_target);
|
||||
progress.setProgress(percent);
|
||||
if (percent === 100) {
|
||||
progress.setStatus("上傳中,請稍候...");
|
||||
progress.toggleCancel(false, this);
|
||||
} else {
|
||||
progress.setStatus("上傳中,請稍候...");
|
||||
progress.toggleCancel(true, this);
|
||||
}
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadSuccess(file, serverData) {
|
||||
try {
|
||||
//addImage("ShowThumbnail.aspx?id=" + serverData);
|
||||
|
||||
var progress = new FileProgress(file, this.customSettings.upload_target);
|
||||
|
||||
progress.setStatus("Thumbnail Created.");
|
||||
progress.toggleCancel(false);
|
||||
|
||||
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadComplete(file) {
|
||||
try {
|
||||
/* I want the next upload to continue automatically so I'll call startUpload here */
|
||||
if (this.getStats().files_queued > 0) {
|
||||
this.startUpload();
|
||||
} else {
|
||||
var progress = new FileProgress(file, this.customSettings.upload_target);
|
||||
progress.setComplete();
|
||||
progress.setStatus("您所選擇的檔案皆已上傳");
|
||||
progress.toggleCancel(false);
|
||||
}
|
||||
} catch (ex) {
|
||||
this.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function uploadError(file, errorCode, message) {
|
||||
var imageName = "error.gif";
|
||||
var progress;
|
||||
try {
|
||||
switch (errorCode) {
|
||||
case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
|
||||
try {
|
||||
progress = new FileProgress(file, this.customSettings.upload_target);
|
||||
progress.setCancelled();
|
||||
progress.setStatus("Cancelled");
|
||||
progress.toggleCancel(false);
|
||||
}
|
||||
catch (ex1) {
|
||||
this.debug(ex1);
|
||||
}
|
||||
break;
|
||||
case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
|
||||
try {
|
||||
progress = new FileProgress(file, this.customSettings.upload_target);
|
||||
progress.setCancelled();
|
||||
progress.setStatus("Stopped");
|
||||
progress.toggleCancel(true);
|
||||
}
|
||||
catch (ex2) {
|
||||
this.debug(ex2);
|
||||
}
|
||||
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
|
||||
imageName = "uploadlimit.gif";
|
||||
break;
|
||||
default:
|
||||
alert(message);
|
||||
break;
|
||||
}
|
||||
|
||||
addImage("../../App_Script/swfupload/images/" + imageName);
|
||||
|
||||
} catch (ex3) {
|
||||
this.debug(ex3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function addImage(src) {
|
||||
var newImg = document.createElement("img");
|
||||
newImg.style.margin = "5px";
|
||||
|
||||
document.getElementById("thumbnails").appendChild(newImg);
|
||||
if (newImg.filters) {
|
||||
try {
|
||||
newImg.filters.item("DXImageTransform.Microsoft.Alpha").opacity = 0;
|
||||
} catch (e) {
|
||||
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
|
||||
newImg.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + 0 + ')';
|
||||
}
|
||||
} else {
|
||||
newImg.style.opacity = 0;
|
||||
}
|
||||
|
||||
newImg.onload = function () {
|
||||
fadeIn(newImg, 0);
|
||||
};
|
||||
newImg.src = src;
|
||||
}
|
||||
|
||||
function fadeIn(element, opacity) {
|
||||
var reduceOpacityBy = 5;
|
||||
var rate = 30; // 15 fps
|
||||
|
||||
|
||||
if (opacity < 100) {
|
||||
opacity += reduceOpacityBy;
|
||||
if (opacity > 100) {
|
||||
opacity = 100;
|
||||
}
|
||||
|
||||
if (element.filters) {
|
||||
try {
|
||||
element.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity;
|
||||
} catch (e) {
|
||||
// If it is not set initially, the browser will throw an error. This will set it if it is not set yet.
|
||||
element.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')';
|
||||
}
|
||||
} else {
|
||||
element.style.opacity = opacity / 100;
|
||||
}
|
||||
}
|
||||
|
||||
if (opacity < 100) {
|
||||
setTimeout(function () {
|
||||
fadeIn(element, opacity);
|
||||
}, rate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ******************************************
|
||||
* FileProgress Object
|
||||
* Control object for displaying file info
|
||||
* ****************************************** */
|
||||
|
||||
function FileProgress(file, targetID) {
|
||||
this.fileProgressID = "divFileProgress";
|
||||
|
||||
this.fileProgressWrapper = document.getElementById(this.fileProgressID);
|
||||
if (!this.fileProgressWrapper) {
|
||||
this.fileProgressWrapper = document.createElement("div");
|
||||
this.fileProgressWrapper.className = "progressWrapper";
|
||||
this.fileProgressWrapper.id = this.fileProgressID;
|
||||
|
||||
this.fileProgressElement = document.createElement("div");
|
||||
this.fileProgressElement.className = "progressContainer";
|
||||
|
||||
var progressCancel = document.createElement("a");
|
||||
progressCancel.className = "progressCancel";
|
||||
progressCancel.href = "#";
|
||||
progressCancel.style.visibility = "hidden";
|
||||
progressCancel.appendChild(document.createTextNode(" "));
|
||||
|
||||
var progressText = document.createElement("div");
|
||||
progressText.className = "progressName";
|
||||
progressText.appendChild(document.createTextNode(file.name));
|
||||
|
||||
var progressBar = document.createElement("div");
|
||||
progressBar.className = "progressBarInProgress";
|
||||
|
||||
var progressStatus = document.createElement("div");
|
||||
progressStatus.className = "progressBarStatus";
|
||||
progressStatus.innerHTML = " ";
|
||||
|
||||
this.fileProgressElement.appendChild(progressCancel);
|
||||
this.fileProgressElement.appendChild(progressText);
|
||||
this.fileProgressElement.appendChild(progressStatus);
|
||||
this.fileProgressElement.appendChild(progressBar);
|
||||
|
||||
this.fileProgressWrapper.appendChild(this.fileProgressElement);
|
||||
|
||||
document.getElementById(targetID).appendChild(this.fileProgressWrapper);
|
||||
fadeIn(this.fileProgressWrapper, 0);
|
||||
|
||||
} else {
|
||||
this.fileProgressElement = this.fileProgressWrapper.firstChild;
|
||||
this.fileProgressElement.childNodes[1].firstChild.nodeValue = file.name;
|
||||
}
|
||||
|
||||
this.height = this.fileProgressWrapper.offsetHeight;
|
||||
|
||||
}
|
||||
FileProgress.prototype.setProgress = function (percentage) {
|
||||
this.fileProgressElement.className = "progressContainer green";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarInProgress";
|
||||
this.fileProgressElement.childNodes[3].style.width = percentage + "%";
|
||||
};
|
||||
FileProgress.prototype.setComplete = function () {
|
||||
this.fileProgressElement.className = "progressContainer blue";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarComplete";
|
||||
this.fileProgressElement.childNodes[3].style.width = "";
|
||||
|
||||
};
|
||||
FileProgress.prototype.setError = function () {
|
||||
this.fileProgressElement.className = "progressContainer red";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarError";
|
||||
this.fileProgressElement.childNodes[3].style.width = "";
|
||||
|
||||
};
|
||||
FileProgress.prototype.setCancelled = function () {
|
||||
this.fileProgressElement.className = "progressContainer";
|
||||
this.fileProgressElement.childNodes[3].className = "progressBarError";
|
||||
this.fileProgressElement.childNodes[3].style.width = "";
|
||||
|
||||
};
|
||||
FileProgress.prototype.setStatus = function (status) {
|
||||
this.fileProgressElement.childNodes[2].innerHTML = status;
|
||||
};
|
||||
|
||||
FileProgress.prototype.toggleCancel = function (show, swfuploadInstance) {
|
||||
this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden";
|
||||
if (swfuploadInstance) {
|
||||
var fileID = this.fileProgressID;
|
||||
this.fileProgressElement.childNodes[0].onclick = function () {
|
||||
swfuploadInstance.cancelUpload(fileID);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
};
|
||||
BIN
web/App_Script/swfupload/images/XPButtonNoText_160x22.png
Normal file
BIN
web/App_Script/swfupload/images/XPButtonNoText_160x22.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
web/App_Script/swfupload/images/error.gif
Normal file
BIN
web/App_Script/swfupload/images/error.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
web/App_Script/swfupload/images/toobig.gif
Normal file
BIN
web/App_Script/swfupload/images/toobig.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
BIN
web/App_Script/swfupload/images/uploadlimit.gif
Normal file
BIN
web/App_Script/swfupload/images/uploadlimit.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
BIN
web/App_Script/swfupload/images/zerobyte.gif
Normal file
BIN
web/App_Script/swfupload/images/zerobyte.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
345
web/App_Script/swfupload/index.aspx
Normal file
345
web/App_Script/swfupload/index.aspx
Normal file
@@ -0,0 +1,345 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="admin_filemanager_index" %>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" >
|
||||
<head id="Head1" runat="server">
|
||||
<title>已上傳檔案夾</title>
|
||||
<link href="~/App_Script/css/admin.css" rel="stylesheet" type="text/css">
|
||||
|
||||
<style type="text/css">
|
||||
html, body {
|
||||
width:100%;
|
||||
height:100%;
|
||||
background-color: #ffffff;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.picdiv
|
||||
{
|
||||
|
||||
width:140px;
|
||||
text-align:center;
|
||||
padding:5px;
|
||||
float:left;
|
||||
|
||||
}
|
||||
.picdivtd
|
||||
{
|
||||
width:132px;
|
||||
height:132px;
|
||||
border-style:solid;
|
||||
border-color:Silver;
|
||||
border-width:1px;
|
||||
empty-cells:show;
|
||||
background-color:White;
|
||||
padding:0px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
function OpenFile(fileUrl) {
|
||||
window.opener.CKEDITOR.tools.callFunction(<%= Convert.ToString(Request["CKEditorFuncNum"]) %>, fileUrl);
|
||||
//window.opener.SetUrl(fileUrl);
|
||||
window.close();
|
||||
window.opener.focus();
|
||||
}
|
||||
|
||||
</script>
|
||||
<% if (Convert.ToString(Request["mode"])=="upload") {%>
|
||||
<script type="text/javascript" src="../../App_Script/swfupload/swfupload.js"></script>
|
||||
<script type="text/javascript" src="../../App_Script/swfupload/handlers2.js"></script>
|
||||
<script type="text/javascript">
|
||||
var swfu;
|
||||
window.onload = function() {
|
||||
swfu = new SWFUpload({
|
||||
// Backend Settings
|
||||
upload_url: "upload.aspx?dirname=<%=Convert.ToString(Request["dirname"])%>",
|
||||
post_params: {
|
||||
"ASPSESSID": "1"
|
||||
},
|
||||
|
||||
// File Upload Settings
|
||||
file_size_limit: "4 MB",
|
||||
file_types: "*.*",
|
||||
file_types_description: "Files",
|
||||
file_upload_limit: "0", // Zero means unlimited
|
||||
|
||||
// Event Handler Settings - these functions as defined in Handlers.js
|
||||
// The handlers are not part of SWFUpload but are part of my website and control how
|
||||
// my website reacts to the SWFUpload events.
|
||||
file_queue_error_handler: fileQueueError,
|
||||
file_dialog_complete_handler: fileDialogComplete,
|
||||
upload_progress_handler: uploadProgress,
|
||||
upload_error_handler: uploadError,
|
||||
upload_success_handler: uploadSuccess,
|
||||
upload_complete_handler: uploadComplete,
|
||||
|
||||
// Button settings
|
||||
button_image_url: "../../App_Script/swfupload/images/XPButtonNoText_160x22.png",
|
||||
button_placeholder_id: "spanButtonPlaceholder",
|
||||
button_width: 160,
|
||||
button_height: 22,
|
||||
button_text: '<span class="buttonSmall">請選擇要上傳的檔案</span>',
|
||||
button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt;} .buttonSmall { font-size: 12pt; }',
|
||||
button_text_top_padding: 1,
|
||||
button_text_left_padding: 5,
|
||||
|
||||
// Flash Settings
|
||||
flash_url: "../../App_Script/swfupload/swfupload.swf", // Relative to this file
|
||||
|
||||
custom_settings: {
|
||||
upload_target: "divFileProgressContainer"
|
||||
},
|
||||
|
||||
// Debug Settings
|
||||
debug: false
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<% }%>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
//---------------------------------checkbox全選用---------------------------------------------------
|
||||
function Check(parentChk, ChildId) {
|
||||
var oElements = document.getElementsByTagName("INPUT");
|
||||
var bIsChecked = parentChk.checked;
|
||||
|
||||
for (i = 0; i < oElements.length; i++) {
|
||||
if (IsCheckBox(oElements[i]) &&
|
||||
IsMatch(oElements[i].id, ChildId)) {
|
||||
oElements[i].checked = bIsChecked;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function IsMatch(id, ChildId) {
|
||||
var sPattern = '^ctl00_ContentPlaceHolder1_GridView1.*' + ChildId + '$';
|
||||
var sPattern = '^Repeater1_.*' + ChildId + '$';
|
||||
var oRegExp = new RegExp(sPattern);
|
||||
if (oRegExp.exec(id))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function IsCheckBox(chk) {
|
||||
if (chk.type == 'checkbox') return true;
|
||||
else return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<div style="text-align: center">
|
||||
<asp:Label ID="L_login_msg" runat="server" ForeColor="Red"></asp:Label><br />
|
||||
<asp:Panel ID="Panel1" runat="server">
|
||||
<table width="600" align="center">
|
||||
<tr>
|
||||
<td align="center"><font class="title1">檔案(圖片)管理
|
||||
|
||||
<asp:Label ID="L_total" runat="server"></asp:Label></font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><asp:Label ID="L_errmsg" runat="server" /></td>
|
||||
</tr>
|
||||
<tr><td class="td_bg_line"></td></tr>
|
||||
<% if (Convert.ToString(Request["mode"]) !="upload"){%>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<div align="center" class="word5">注意:若為「系統資料夾」或資料夾中尚有資料,則該資料夾無法刪除!</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% }%>
|
||||
|
||||
<tr><td class="td_word150" align="left">
|
||||
<asp:Image ID="Image2" runat="server" ImageUrl="../images/icon09.gif" />
|
||||
<asp:Label ID="L_path" runat="server"></asp:Label>
|
||||
</td></tr>
|
||||
<tr><td class="td_word150" align="center">
|
||||
<asp:Label ID="msg" runat="server" ForeColor="Red"></asp:Label></td></tr>
|
||||
<tr runat ="server" id="tr1"><td class="td_bg_line"></td></tr>
|
||||
</table>
|
||||
|
||||
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
|
||||
<asp:View ID="View1" runat="server">
|
||||
|
||||
<table width="600" cellpadding="0" cellspacing="0" align="center">
|
||||
<tr><td align="left">
|
||||
|
||||
<div style="width:600px">
|
||||
<div style="float:left">
|
||||
<input type="checkbox" id="chkAll" name="chkAll" onClick="Check(this,'CheckBox1')" /><label for="chkAll">全選</label>
|
||||
|
||||
<span style="margin-left:20px">排序方式:</span>
|
||||
<asp:DropDownList ID="sortWay" runat="server" AutoPostBack="true" OnSelectedIndexChanged="sortWay_SelectedIndexChanged">
|
||||
<asp:ListItem Value="c_date$desc" Text="依日期"></asp:ListItem>
|
||||
<asp:ListItem Value="filename$asc" Text="依檔名"></asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
</div>
|
||||
<asp:Panel ID="searchPanel" style="float:right" runat="server" DefaultButton="searchBt">
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td>搜尋此目錄的檔案:</td>
|
||||
<td><asp:TextBox ID="search" runat="server"></asp:TextBox></td>
|
||||
<td><asp:LinkButton ID="searchBt" runat="server" CausesValidation="false" OnClick="searchBt_Click"><img src="../images/04.gif" border="0" /></asp:LinkButton></td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
</div>
|
||||
|
||||
<asp:Repeater id=Repeater1 runat="server" OnItemDataBound="Repeater1_ItemDataBound">
|
||||
<ItemTemplate>
|
||||
|
||||
<div class="picdiv">
|
||||
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse;">
|
||||
<tr><td align="center" valign="middle" class="picdivtd"><%#Eval("review") %></td></tr></table>
|
||||
<div style="width:120px; height:20px; overflow:hidden; text-align:left">
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr><td width="10" valign="top">
|
||||
<asp:CheckBox ID="CheckBox1" Visible="false" runat="server" />
|
||||
</td><td align="left" style="color:blue">
|
||||
<%#Eval("filename")%>
|
||||
<asp:ImageButton ID="ImageButton1" runat="server" Visible="false" OnClientClick="return confirm('是否確定刪除此資料夾?\n\n注意,若此資料夾中尚有資料時,將無法刪除!');" CommandArgument='<%#Eval("filename2") + "|" + Eval("filekind")%>' OnClick="ImageButton1_Click" ImageUrl="../images/del.gif" />
|
||||
</td></tr>
|
||||
</table>
|
||||
</div>
|
||||
<div style="float :right ; text-align:right; color:green">
|
||||
<%#Eval("filesize") %>
|
||||
</div>
|
||||
<asp:HiddenField ID="filekind" runat="server" />
|
||||
</div>
|
||||
|
||||
<asp:Panel ID="splitDiv" style="clear:both" Visible="false" runat="server"></asp:Panel>
|
||||
|
||||
</ItemTemplate>
|
||||
</asp:Repeater>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="600" align="center">
|
||||
<tr><td align="center">
|
||||
<asp:LinkButton ID="LinkButton1" Font-Underline="false" OnClick="LinkButton1_Click" runat="server">上一頁</asp:LinkButton>
|
||||
|
|
||||
<asp:LinkButton ID="LinkButton2" Font-Underline="false" OnClick="LinkButton2_Click" runat="server">下一頁</asp:LinkButton>
|
||||
|
|
||||
第
|
||||
<asp:DropDownList ID="nowpage" AutoPostBack="true" runat="server" OnSelectedIndexChanged="nowpage_SelectedIndexChanged">
|
||||
</asp:DropDownList>
|
||||
頁,共
|
||||
<asp:Label ID="maxpage" runat="server"></asp:Label>
|
||||
頁,總計
|
||||
<asp:Label ID="dirTotal" runat="server"></asp:Label>
|
||||
個資料夾
|
||||
<asp:Label ID="total" runat="server"></asp:Label>
|
||||
個檔案
|
||||
</td></tr>
|
||||
<tr><td class="td_bg_line"></td></tr>
|
||||
<tr><td align="center" valign="bottom" height="30">
|
||||
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="../images/upload.gif" OnClick="ImageButton2_Click" />
|
||||
<asp:ImageButton ID="dell_all" runat="server" ImageUrl="~/admin/images/del_all.gif" OnClientClick="return confirm('是否確定刪除勾選的檔案?');" OnClick="dell_all_Click" /></td></tr>
|
||||
<tr><td class="td_bg_line"></td></tr>
|
||||
</table>
|
||||
<asp:Panel ID="Panel2" runat="server">
|
||||
<asp:Panel ID="Panel3" runat="server" Visible="false">
|
||||
<table align="center" bgcolor="#ffffff" border="1" cellpadding="2" cellspacing="0" width="600">
|
||||
<tr>
|
||||
<td class="td4a" colspan="2">
|
||||
<div align="center">檔案上傳系統</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td1a" width="100">
|
||||
<div align="right">上傳1:</div>
|
||||
</td>
|
||||
<td class="td2a">
|
||||
<input id="file1" runat="server" name="file" type="file" size="50" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td1a">
|
||||
<div align="right">上傳2:</div>
|
||||
</td>
|
||||
<td class="td2a">
|
||||
<input id="file2" runat="server" name="file" type="file" size="50" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td1a">
|
||||
<div align="right">上傳3:</div>
|
||||
</td>
|
||||
<td class="td2a"><input id="file3" runat="server" name="file" type="file" size="50" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" class="td4a" colspan="2" height="30"><asp:ImageButton ID="Button1" runat="server" ImageUrl="../images/upload.gif" OnClick="Button1_Click" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="600" align="center">
|
||||
<tr><td class="td_bg_line"></td></tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
|
||||
|
||||
|
||||
<table align="center" bgcolor="#ffffff" border="1" cellpadding="2" cellspacing="0" width="600">
|
||||
<tr>
|
||||
<td class="td4a" colspan="2">
|
||||
<div align="center">
|
||||
新增資料夾</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td1a" width="100">
|
||||
<div align="right">
|
||||
資料夾名稱:</div>
|
||||
</td>
|
||||
<td class="td2a">
|
||||
<asp:TextBox ID="folder_name" runat="server" Width="400px"></asp:TextBox>
|
||||
<asp:RegularExpressionValidator ValidationGroup="folder_va" ControlToValidate="folder_name" Display="Dynamic" ErrorMessage="<div>只能輸入英文或數字!</div>" ID="RegularExpressionValidator11" runat="server" ValidationExpression="^[A-Za-z0-9]+$" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" class="td4a" colspan="2" height="30"><asp:ImageButton ID="creat_folder" ValidationGroup="folder_va" OnClick="creat_folder_Click" runat="server" ImageUrl="~/admin/images/newfolder.gif" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="600" align="center">
|
||||
<tr><td class="td_bg_line"></td></tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
</asp:View>
|
||||
<asp:View ID="View2" runat="server">
|
||||
<center>
|
||||
<div id="swfu_container" style="margin: 0px 10px;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td><span id="spanButtonPlaceholder"></span></td>
|
||||
<td width="20"></td>
|
||||
<td><asp:Button ID="Button2" runat="server" Text="返回" OnClick="Button2_Click" /></td></tr>
|
||||
</table>
|
||||
|
||||
<div id="divFileProgressContainer" style="height: 75px;"></div>
|
||||
<div id="thumbnails"></div>
|
||||
</div>
|
||||
<table width="600" align="center">
|
||||
<tr><td class="td_bg_line"></td></tr>
|
||||
</table>
|
||||
</center>
|
||||
</asp:View>
|
||||
</asp:MultiView>
|
||||
|
||||
|
||||
<table width="600" align="center">
|
||||
<tr>
|
||||
<td height="30" valign="bottom" align="center">
|
||||
<a href="javascript:window.close()"><asp:Image ID="Image1" runat="server" ImageUrl="~/admin/images/close.gif" /></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</asp:Panel>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
592
web/App_Script/swfupload/index.aspx.cs
Normal file
592
web/App_Script/swfupload/index.aspx.cs
Normal file
@@ -0,0 +1,592 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
|
||||
public partial class admin_filemanager_index : System.Web.UI.Page
|
||||
{
|
||||
|
||||
string db = ConfigurationManager.ConnectionStrings["shopConn"].ConnectionString;
|
||||
string p_name = ConfigurationManager.ConnectionStrings["shopConn"].ProviderName;
|
||||
string[] systemDirs = ConfigurationManager.AppSettings["systemDirs"].Split(',');
|
||||
string scc = ConfigurationManager.AppSettings["shopCarCode"].ToString();
|
||||
MyWeb.web_config webconfig = new MyWeb.web_config();
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack) {
|
||||
|
||||
if ((Request.Cookies[scc + "_ezFileSort"] != null))
|
||||
{
|
||||
sortWay.SelectedValue = Request.Cookies[scc + "_ezFileSort"].Value;
|
||||
}
|
||||
saveSort(false);
|
||||
|
||||
MyWeb.admin admin = new MyWeb.admin();
|
||||
if (admin.isLoign())
|
||||
{
|
||||
//定義初始路徑
|
||||
ViewState["root_path"] = "../../upload/";
|
||||
|
||||
//參數,如有需要增加,請接續後面
|
||||
ViewState["QueryString"] = "&CKEditorFuncNum=" + Convert.ToString(Request["CKEditorFuncNum"]) + "&rtnobj=" + Convert.ToString(Request["rtnobj"]) + "&CKEditor=" + Convert.ToString(Request["CKEditor"]) + "&langCode=" + Convert.ToString(Request["langCode"]);
|
||||
|
||||
|
||||
string http_path = "";
|
||||
MyWeb.sql sql = new MyWeb.sql();
|
||||
DataTable dt = sql.selectTable(db, p_name, "SELECT pic_url FROM company");
|
||||
if (dt.Rows.Count>0){
|
||||
http_path = dt.Rows[0]["pic_url"].ToString();
|
||||
}
|
||||
ViewState["http_path"] = http_path + "/upload/"; //定義上傳圖片實體路徑
|
||||
ViewState["total_bytes"] = 0; //定義總檔案大小初始值
|
||||
|
||||
if (!webconfig.isStrNull(Request["kw"]))
|
||||
{
|
||||
search.Text = Request["kw"];
|
||||
}
|
||||
|
||||
if (Convert.ToString(Request["mode"]) == "upload")
|
||||
{
|
||||
MultiView1.ActiveViewIndex = 1;
|
||||
L_path.Text = "";
|
||||
Image2.Visible = false;
|
||||
tr1.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
load_dir_files(); //檔案列表
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Response.Clear();
|
||||
Response.StatusCode = 404;
|
||||
Response.End();
|
||||
//Panel1.Visible = false;
|
||||
//L_login_msg.Text = "<br><br><br><br><br><br>您尚未登錄管理!";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#region 檔案列表
|
||||
|
||||
public void load_dir_files() {
|
||||
|
||||
//計算總檔案大小
|
||||
total_bytes("");
|
||||
|
||||
DataTable dt = new DataTable("Dt1");
|
||||
|
||||
//定義DataTable欄位名稱
|
||||
dt.Columns.Add(new DataColumn("filename"));
|
||||
dt.Columns.Add(new DataColumn("review"));
|
||||
dt.Columns.Add(new DataColumn("filesize"));
|
||||
dt.Columns.Add(new DataColumn("c_date"));
|
||||
dt.Columns.Add(new DataColumn("filename2"));
|
||||
dt.Columns.Add(new DataColumn("filekind"));
|
||||
dt.Columns.Add(new DataColumn("fileqty"));
|
||||
dt.Columns.Add(new DataColumn("isDir"));
|
||||
|
||||
//取得目錄路徑
|
||||
string dirpath = "";
|
||||
string dirpath2 = "";
|
||||
string dirpath3 = "";
|
||||
string dirpath4 = "";
|
||||
|
||||
if (Convert.ToString(Request["dirname"]) != "" & Request["dirname"]!=null)
|
||||
{
|
||||
|
||||
dirpath = "/" + Convert.ToString(Request["dirname"]);
|
||||
dirpath4 = Convert.ToString(Request["dirname"]) + "/";
|
||||
string[] v = Convert.ToString(Request["dirname"]).Split('/');
|
||||
for (int ii = 0; ii < v.Length; ii++) {
|
||||
if (dirpath2 != "")
|
||||
{
|
||||
dirpath2 += "/" + v[ii];
|
||||
if (ii == v.Length - 1)
|
||||
{
|
||||
dirpath3 += "/" + v[ii];
|
||||
}
|
||||
else {
|
||||
dirpath3 += "/<a href='index.aspx?dirname=" + HttpUtility.UrlEncode(dirpath2) + ViewState["QueryString"].ToString() + "'>" + HttpUtility.HtmlEncode(v[ii]) + "</a>";
|
||||
}
|
||||
}
|
||||
else {
|
||||
dirpath2 += v[ii];
|
||||
if (ii == v.Length - 1)
|
||||
{
|
||||
dirpath3 += v[ii];
|
||||
}
|
||||
else {
|
||||
dirpath3 += "<a href='index.aspx?dirname=" + HttpUtility.UrlEncode(dirpath2) + ViewState["QueryString"].ToString() + "'>" + HttpUtility.HtmlEncode(v[ii]) + "</a>";
|
||||
}
|
||||
}
|
||||
}
|
||||
L_path.Text = "<a href='index.aspx" + ViewState["QueryString"].ToString().Replace("&CKEditorFuncNum=", "?CKEditorFuncNum=") + "'>根目錄</a>/" + dirpath3;
|
||||
}
|
||||
else {
|
||||
dirpath = "";
|
||||
dirpath4 = "";
|
||||
L_path.Text = "";
|
||||
Image2.Visible = false;
|
||||
tr1.Visible = false;
|
||||
}
|
||||
|
||||
string kw ="";
|
||||
if (!webconfig.isStrNull(Request["kw"]))
|
||||
{
|
||||
kw = Request["kw"];
|
||||
}
|
||||
|
||||
//定義資料
|
||||
string path = Server.MapPath(ViewState["root_path"].ToString() + dirpath);
|
||||
DirectoryInfo dirInfo= new DirectoryInfo(path);
|
||||
DirectoryInfo[] subDirs = dirInfo.GetDirectories();
|
||||
FileInfo[] subFiles = dirInfo.GetFiles();
|
||||
|
||||
//將資料夾名稱填入DataTable
|
||||
string child_dirinfo = "";
|
||||
string new_dir = "";
|
||||
for (int i = 0; i < subDirs.Length; i++) {
|
||||
|
||||
bool chkSearch = true;
|
||||
if (kw != "")
|
||||
{
|
||||
if (subDirs[i].Name.ToLower().IndexOf(kw.ToLower()) == -1)
|
||||
{
|
||||
chkSearch = false;
|
||||
}
|
||||
}
|
||||
if (chkSearch)
|
||||
{
|
||||
|
||||
//取得子資料夾資訊
|
||||
string path2 = Server.MapPath(ViewState["root_path"].ToString() + dirpath + "/" + subDirs[i].Name);
|
||||
DirectoryInfo dirInfo2 = new DirectoryInfo(path2);
|
||||
DirectoryInfo[] subDirs2 = dirInfo2.GetDirectories();
|
||||
FileInfo[] subFiles2 = dirInfo2.GetFiles();
|
||||
|
||||
child_dirinfo = "內有 <span class=\"text-primary\">" + subDirs2.Length.ToString() + "</span> 資料夾<br><span class=\"text-primary\">" + subFiles2.Length + "</span> 個檔案";
|
||||
string fileqty = "";
|
||||
string filekind = "";
|
||||
|
||||
filekind = "A";
|
||||
fileqty = "B";
|
||||
bool chkAgin = true;
|
||||
//upload的目錄下
|
||||
if (dirpath == "")
|
||||
{
|
||||
foreach (string chkDir in systemDirs)
|
||||
{
|
||||
if (subDirs[i].Name.ToLower() == chkDir.ToLower())
|
||||
{
|
||||
filekind = "C";
|
||||
fileqty = "B";
|
||||
chkAgin = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (chkAgin & subDirs2.Length == 0 & subFiles2.Length == 0)
|
||||
{
|
||||
filekind = "A";
|
||||
fileqty = "A";
|
||||
}
|
||||
|
||||
|
||||
if (Convert.ToString(Request["dirname"]) != "" & Request["dirname"] != null)
|
||||
{
|
||||
new_dir = Request["dirname"] + "/" + subDirs[i].Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_dir = subDirs[i].Name;
|
||||
}
|
||||
|
||||
string subfilename = "<span title=\"" + HttpUtility.HtmlEncode(subDirs[i].Name) + "\">" + HttpUtility.HtmlEncode(subDirs[i].Name) + "</span>";
|
||||
string review_file = "<a href=\"index.aspx?dirname=" + HttpUtility.UrlEncode(new_dir) + ViewState["QueryString"].ToString() + "\" title=\"" + HttpUtility.HtmlEncode(subDirs[i].Name) + "\"><img src=\"images/dir.png\" border=\"0\" width=\"100\" /></a>";
|
||||
|
||||
dt.Rows.Add(subfilename, review_file, child_dirinfo, subDirs[i].CreationTime, subDirs[i].Name, filekind, fileqty, 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dirTotal.Text = subDirs.Length.ToString();
|
||||
//將檔案名稱填入DataTable
|
||||
|
||||
for (int j = 0; j < subFiles.Length; j++)
|
||||
{
|
||||
|
||||
bool chkSearch = true;
|
||||
if (kw != "")
|
||||
{
|
||||
if (subFiles[j].Name.ToLower().IndexOf(kw.ToLower()) == -1)
|
||||
{
|
||||
chkSearch = false;
|
||||
}
|
||||
}
|
||||
if (chkSearch)
|
||||
{
|
||||
|
||||
string[] tmp = subFiles[j].Name.Split('.');
|
||||
string fileSubName = tmp[tmp.Length - 1].ToLower();
|
||||
string viewPic = "";
|
||||
if (fileSubName == "jpg" | fileSubName == "jepg" | fileSubName == "gif" | fileSubName == "png")
|
||||
{
|
||||
viewPic = "<img src=\"../../App_Script/display.ashx?file=" + dirpath4 + subFiles[j].Name + "&w=120&h=120\" border=\"0\" />";
|
||||
}
|
||||
else
|
||||
{
|
||||
viewPic = "<img src=\"images/" + picLog(fileSubName) + ".png\" border=\"0\" />";
|
||||
}
|
||||
|
||||
string subfilename = "<span title=\"" + HttpUtility.HtmlEncode(subFiles[j].Name) + "\">" + HttpUtility.HtmlEncode(subFiles[j].Name) + "</span>";
|
||||
string review_file = "<a href=\"#\" title=\"" + HttpUtility.HtmlEncode(subFiles[j].Name) + "\" onclick=\"OpenFile('" + ViewState["http_path"] + dirpath4 + HttpUtility.UrlEncode(subFiles[j].Name) + "');return false;\">" + viewPic + "</a>";
|
||||
dt.Rows.Add(subfilename, review_file, (subFiles[j].Length / 1024).ToString("0.00") + " KB", subFiles[j].CreationTime, subFiles[j].Name, "B", "X", 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
total.Text = subFiles.Length.ToString();
|
||||
|
||||
dt.DefaultView.Sort = "isDir desc, " + sortWay.SelectedValue.Replace("$", " ");
|
||||
|
||||
PagedDataSource objPage = new PagedDataSource();
|
||||
objPage.DataSource = dt.DefaultView;
|
||||
objPage.AllowPaging = true;
|
||||
objPage.PageSize = 12;
|
||||
int CurPage = 1;
|
||||
if (Request["page"]!=null)
|
||||
{
|
||||
CurPage = Convert.ToInt32(Request["page"]);
|
||||
}
|
||||
if (CurPage > objPage.PageCount)
|
||||
{
|
||||
CurPage = objPage.PageCount;
|
||||
}
|
||||
objPage.CurrentPageIndex = CurPage - 1;
|
||||
|
||||
for (int i = 1; i <= objPage.PageCount; i++) {
|
||||
nowpage.Items.Add(i.ToString());
|
||||
}
|
||||
|
||||
if (nowpage.Items.Count > 0) {
|
||||
nowpage.SelectedValue = CurPage.ToString(); //顯示目前第幾頁
|
||||
}
|
||||
|
||||
maxpage.Text = objPage.PageCount.ToString(); //顯示最大頁數
|
||||
|
||||
Repeater1.DataSource = objPage;
|
||||
Repeater1.DataBind();
|
||||
}
|
||||
|
||||
|
||||
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
|
||||
{
|
||||
DataRowView data = (DataRowView)e.Item.DataItem;
|
||||
|
||||
if (e.Item.ItemIndex % 4 == 3) {
|
||||
Panel splitDiv = (Panel)e.Item.FindControl("splitDiv");
|
||||
splitDiv.Visible = true;
|
||||
}
|
||||
|
||||
CheckBox CheckBox1 = (CheckBox)e.Item.FindControl("CheckBox1");
|
||||
if (data["filekind"].ToString() == "B" | (data["filekind"].ToString() == "A" & data["fileqty"].ToString() == "A"))
|
||||
{
|
||||
CheckBox1.Visible = true;
|
||||
}
|
||||
|
||||
HiddenField filekind = (HiddenField)e.Item.FindControl("filekind");
|
||||
filekind.Value = data["filekind"].ToString();
|
||||
|
||||
}
|
||||
|
||||
public string picLog(string subName){
|
||||
string rtn = "|ai|asp|aspx|js|jsp|pdf|php|psd|swf|txt|";
|
||||
if (rtn.IndexOf("|" + subName + "|", 0) > -1)
|
||||
{
|
||||
return subName;
|
||||
}
|
||||
else if (subName == "xls" | subName == "xlsx")
|
||||
{
|
||||
return "excel";
|
||||
}
|
||||
else if (subName == "doc" | subName == "docx")
|
||||
{
|
||||
return "word";
|
||||
}
|
||||
else if (subName == "zip" | subName == "rar")
|
||||
{
|
||||
return "zip";
|
||||
}
|
||||
else if (subName == "htm" | subName == "html")
|
||||
{
|
||||
return "html";
|
||||
}
|
||||
else if (subName == "ppt" | subName == "pps" | subName == "pptx" | subName == "ppsx")
|
||||
{
|
||||
return "powerpoint";
|
||||
}
|
||||
else if (subName == "bmp" | subName == "tif")
|
||||
{
|
||||
return "photo";
|
||||
}
|
||||
else if (subName == "wmv" | subName == "mp4" | subName == "rm" | subName == "mov")
|
||||
{
|
||||
return "video";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
protected void nowpage_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
GoToPage(Convert.ToInt32(nowpage.SelectedValue));
|
||||
}
|
||||
|
||||
protected void LinkButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
int pg = Convert.ToInt32(nowpage.SelectedValue);
|
||||
GoToPage((pg - 1 > 0 ? pg - 1 : 1));
|
||||
}
|
||||
protected void LinkButton2_Click(object sender, EventArgs e)
|
||||
{
|
||||
int pg = Convert.ToInt32(nowpage.SelectedValue);
|
||||
int maxpg = Convert.ToInt32(maxpage.Text);
|
||||
GoToPage((pg + 1 <= maxpg ? pg + 1 : maxpg));
|
||||
}
|
||||
|
||||
public void GoToPage(int p) {
|
||||
MyWeb.web_config web_config = new MyWeb.web_config();
|
||||
string url = web_config.rtnQueryString("page");
|
||||
Response.Redirect(url + "&page=" + p.ToString());
|
||||
}
|
||||
|
||||
//計算目前總檔案大小
|
||||
public void total_bytes(string dirpath)
|
||||
{
|
||||
string path = Server.MapPath(ViewState["root_path"].ToString() + dirpath);
|
||||
DirectoryInfo dirInfo = new DirectoryInfo(path);
|
||||
DirectoryInfo[] subDirs = dirInfo.GetDirectories();
|
||||
FileInfo[] subFiles = dirInfo.GetFiles();
|
||||
long all_bytes = Convert.ToInt64(ViewState["total_bytes"]);
|
||||
for (int j = 0; j < subFiles.Length; j++)
|
||||
{
|
||||
all_bytes += subFiles[j].Length;
|
||||
}
|
||||
//Response.Write("路徑=" + dirpath + "<br>");
|
||||
//Response.Write("個別資料夾總和=" + (all_bytes / 1024).ToString("0.00") + "<br><br><br>");
|
||||
ViewState["total_bytes"] = all_bytes;
|
||||
for (int j = 0; j < subDirs.Length; j++)
|
||||
{
|
||||
total_bytes(dirpath + "/" + subDirs[j].Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 刪除
|
||||
|
||||
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
|
||||
{
|
||||
string[] v = ((ImageButton)sender).CommandArgument.Split('|');
|
||||
if (v[1] == "A") {
|
||||
string path = Server.MapPath(Convert.ToString(ViewState["root_path"]) + Convert.ToString(Request["dirname"]) + "/" + v[0]);
|
||||
DirectoryInfo DirectoryInfo = new DirectoryInfo(path);
|
||||
if (DirectoryInfo.Exists)
|
||||
{
|
||||
try
|
||||
{
|
||||
DirectoryInfo.Delete();
|
||||
Response.Redirect("index.aspx?dirname=" + Convert.ToString(Request["dirname"]) + ViewState["QueryString"].ToString());
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
msg.Text = "(刪除失敗,因為要刪除資料夾不是空的!)";
|
||||
}
|
||||
}
|
||||
else {
|
||||
msg.Text = "(要刪除的資料夾:<font color=blue>" + v[0] + "</font> 不存在!!)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void dell_all_Click(object sender, ImageClickEventArgs e)
|
||||
{
|
||||
|
||||
CheckBox cbox;
|
||||
ImageButton img;
|
||||
|
||||
foreach (RepeaterItem item in Repeater1.Items)
|
||||
{
|
||||
|
||||
cbox = (CheckBox)item.FindControl("CheckBox1");
|
||||
img = (ImageButton)item.FindControl("ImageButton1");
|
||||
string[] v = img.CommandArgument.Split('|');
|
||||
if (cbox.Checked) {
|
||||
|
||||
string path = Server.MapPath(Convert.ToString(ViewState["root_path"]) + Convert.ToString(Request["dirname"]) + "/" + v[0]);
|
||||
HiddenField filekind = (HiddenField)item.FindControl("filekind");
|
||||
if (filekind.Value == "A")
|
||||
{
|
||||
DirectoryInfo DirectoryInfo = new DirectoryInfo(path);
|
||||
if (DirectoryInfo.Exists)
|
||||
{
|
||||
try
|
||||
{
|
||||
DirectoryInfo.Delete();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
msg.Text = "(刪除失敗,因為要刪除資料夾不是空的!)";
|
||||
}
|
||||
}
|
||||
else {
|
||||
msg.Text = "(要刪除的資料夾:<font color=blue>" + v[0] + "</font> 不存在!!)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FileInfo FileInfo = new FileInfo(path);
|
||||
if (FileInfo.Exists)
|
||||
{
|
||||
FileInfo.Delete();
|
||||
}
|
||||
else {
|
||||
msg.Text = "(要刪除的檔案:<font color=blue>" + v[0] + "</font> 不存在!!)";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GoToPage(Convert.ToInt32(nowpage.SelectedValue));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 建資料夾
|
||||
|
||||
protected void creat_folder_Click(object sender, ImageClickEventArgs e)
|
||||
{
|
||||
string path = Server.MapPath(Convert.ToString(ViewState["root_path"]) + Convert.ToString(Request["dirname"]) + "/" + folder_name.Text);
|
||||
DirectoryInfo DirectoryInfo = new DirectoryInfo(path);
|
||||
if (DirectoryInfo.Exists)
|
||||
{
|
||||
msg.Text = "(資料夾名稱已存在,無法重覆新增!)";
|
||||
}
|
||||
else
|
||||
{
|
||||
DirectoryInfo.Create();
|
||||
Response.Redirect("index.aspx?dirname=" + Convert.ToString(Request["dirname"]) + ViewState["QueryString"].ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 上傳檔案
|
||||
|
||||
protected void Button1_Click(object sender, ImageClickEventArgs e)
|
||||
{
|
||||
string up_path = Server.MapPath( Convert.ToString(ViewState["root_path"]) + Convert.ToString(Request["dirname"]));
|
||||
HttpFileCollection objFileCollection = Request.Files;
|
||||
HttpPostedFile file;
|
||||
int counter = 0;
|
||||
for (int i = 0; i < objFileCollection.Count; i++) {
|
||||
file = objFileCollection[i];
|
||||
if (file.ContentLength != null) {
|
||||
file.SaveAs(up_path + "/" + Path.GetFileName(file.FileName));
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
if (counter == 0)
|
||||
{
|
||||
msg.Text = "(請選擇要上傳的檔案!)";
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.Text = "(上傳【" + counter.ToString() + "】個檔案成功!)";
|
||||
Response.Redirect("index.aspx?dirname=" + Convert.ToString(Request["dirname"]) + ViewState["QueryString"].ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 批次上傳
|
||||
|
||||
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
|
||||
{
|
||||
string url = Request.Url.AbsoluteUri;
|
||||
if (url.IndexOf(".aspx?", 0) > -1)
|
||||
{
|
||||
url += "&mode=upload";
|
||||
}
|
||||
else {
|
||||
url += "?mode=upload";
|
||||
}
|
||||
Response.Redirect(url);
|
||||
}
|
||||
|
||||
protected void Button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
string url = Request.Url.AbsoluteUri;
|
||||
url = url.Replace("&mode=upload", "");
|
||||
url = url.Replace("?mode=upload", "");
|
||||
string[] v = url.Split('?');
|
||||
if (v.Length == 0) {
|
||||
url = url.Replace("&CKEditorFuncNum=", "?CKEditorFuncNum=");
|
||||
}
|
||||
Response.Redirect(url);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 排序方式
|
||||
protected void sortWay_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
saveSort(true);
|
||||
}
|
||||
protected void saveSort(bool refresh)
|
||||
{
|
||||
Response.Cookies[scc + "_ezFileSort"].Value = sortWay.SelectedValue;
|
||||
Response.Cookies[scc + "_ezFileSort"].Expires = DateTime.Now.AddYears(1);
|
||||
if (refresh) {
|
||||
Response.Redirect(Request.Url.AbsoluteUri);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 搜尋
|
||||
|
||||
protected void searchBt_Click(object sender, EventArgs e)
|
||||
{
|
||||
search.Text = search.Text.Trim();
|
||||
string kwStr = "";
|
||||
if (search.Text != "")
|
||||
{
|
||||
kwStr = "&kw=" + Server.UrlEncode(search.Text);
|
||||
}
|
||||
string[] q = { "kw", "page" };
|
||||
Response.Redirect(Request.Url.AbsolutePath + webconfig.rtnQueryString(q) + kwStr);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
980
web/App_Script/swfupload/swfupload.js
Normal file
980
web/App_Script/swfupload/swfupload.js
Normal file
@@ -0,0 +1,980 @@
|
||||
/**
|
||||
* SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
|
||||
*
|
||||
* mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/App_Script/swfupload/, http://www.vinterwebb.se/
|
||||
*
|
||||
* SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilz<6C>n and Mammon Media and is released under the MIT License:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* ******************* */
|
||||
/* Constructor & Init */
|
||||
/* ******************* */
|
||||
var SWFUpload;
|
||||
|
||||
if (SWFUpload == undefined) {
|
||||
SWFUpload = function (settings) {
|
||||
this.initSWFUpload(settings);
|
||||
};
|
||||
}
|
||||
|
||||
SWFUpload.prototype.initSWFUpload = function (settings) {
|
||||
try {
|
||||
this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
|
||||
this.settings = settings;
|
||||
this.eventQueue = [];
|
||||
this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
|
||||
this.movieElement = null;
|
||||
|
||||
|
||||
// Setup global control tracking
|
||||
SWFUpload.instances[this.movieName] = this;
|
||||
|
||||
// Load the settings. Load the Flash movie.
|
||||
this.initSettings();
|
||||
this.loadFlash();
|
||||
this.displayDebugInfo();
|
||||
} catch (ex) {
|
||||
delete SWFUpload.instances[this.movieName];
|
||||
throw ex;
|
||||
}
|
||||
};
|
||||
|
||||
/* *************** */
|
||||
/* Static Members */
|
||||
/* *************** */
|
||||
SWFUpload.instances = {};
|
||||
SWFUpload.movieCount = 0;
|
||||
SWFUpload.version = "2.2.0 2009-03-25";
|
||||
SWFUpload.QUEUE_ERROR = {
|
||||
QUEUE_LIMIT_EXCEEDED : -100,
|
||||
FILE_EXCEEDS_SIZE_LIMIT : -110,
|
||||
ZERO_BYTE_FILE : -120,
|
||||
INVALID_FILETYPE : -130
|
||||
};
|
||||
SWFUpload.UPLOAD_ERROR = {
|
||||
HTTP_ERROR : -200,
|
||||
MISSING_UPLOAD_URL : -210,
|
||||
IO_ERROR : -220,
|
||||
SECURITY_ERROR : -230,
|
||||
UPLOAD_LIMIT_EXCEEDED : -240,
|
||||
UPLOAD_FAILED : -250,
|
||||
SPECIFIED_FILE_ID_NOT_FOUND : -260,
|
||||
FILE_VALIDATION_FAILED : -270,
|
||||
FILE_CANCELLED : -280,
|
||||
UPLOAD_STOPPED : -290
|
||||
};
|
||||
SWFUpload.FILE_STATUS = {
|
||||
QUEUED : -1,
|
||||
IN_PROGRESS : -2,
|
||||
ERROR : -3,
|
||||
COMPLETE : -4,
|
||||
CANCELLED : -5
|
||||
};
|
||||
SWFUpload.BUTTON_ACTION = {
|
||||
SELECT_FILE : -100,
|
||||
SELECT_FILES : -110,
|
||||
START_UPLOAD : -120
|
||||
};
|
||||
SWFUpload.CURSOR = {
|
||||
ARROW : -1,
|
||||
HAND : -2
|
||||
};
|
||||
SWFUpload.WINDOW_MODE = {
|
||||
WINDOW : "window",
|
||||
TRANSPARENT : "transparent",
|
||||
OPAQUE : "opaque"
|
||||
};
|
||||
|
||||
// Private: takes a URL, determines if it is relative and converts to an absolute URL
|
||||
// using the current site. Only processes the URL if it can, otherwise returns the URL untouched
|
||||
SWFUpload.completeURL = function(url) {
|
||||
if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
|
||||
return url;
|
||||
}
|
||||
|
||||
var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
|
||||
|
||||
var indexSlash = window.location.pathname.lastIndexOf("/");
|
||||
if (indexSlash <= 0) {
|
||||
path = "/";
|
||||
} else {
|
||||
path = window.location.pathname.substr(0, indexSlash) + "/";
|
||||
}
|
||||
|
||||
return /*currentURL +*/ path + url;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* ******************** */
|
||||
/* Instance Members */
|
||||
/* ******************** */
|
||||
|
||||
// Private: initSettings ensures that all the
|
||||
// settings are set, getting a default value if one was not assigned.
|
||||
SWFUpload.prototype.initSettings = function () {
|
||||
this.ensureDefault = function (settingName, defaultValue) {
|
||||
this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
|
||||
};
|
||||
|
||||
// Upload backend settings
|
||||
this.ensureDefault("upload_url", "");
|
||||
this.ensureDefault("preserve_relative_urls", false);
|
||||
this.ensureDefault("file_post_name", "Filedata");
|
||||
this.ensureDefault("post_params", {});
|
||||
this.ensureDefault("use_query_string", false);
|
||||
this.ensureDefault("requeue_on_error", false);
|
||||
this.ensureDefault("http_success", []);
|
||||
this.ensureDefault("assume_success_timeout", 0);
|
||||
|
||||
// File Settings
|
||||
this.ensureDefault("file_types", "*.*");
|
||||
this.ensureDefault("file_types_description", "All Files");
|
||||
this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
|
||||
this.ensureDefault("file_upload_limit", 0);
|
||||
this.ensureDefault("file_queue_limit", 0);
|
||||
|
||||
// Flash Settings
|
||||
this.ensureDefault("flash_url", "swfupload.swf");
|
||||
this.ensureDefault("prevent_swf_caching", true);
|
||||
|
||||
// Button Settings
|
||||
this.ensureDefault("button_image_url", "");
|
||||
this.ensureDefault("button_width", 1);
|
||||
this.ensureDefault("button_height", 1);
|
||||
this.ensureDefault("button_text", "");
|
||||
this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
|
||||
this.ensureDefault("button_text_top_padding", 0);
|
||||
this.ensureDefault("button_text_left_padding", 0);
|
||||
this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
|
||||
this.ensureDefault("button_disabled", false);
|
||||
this.ensureDefault("button_placeholder_id", "");
|
||||
this.ensureDefault("button_placeholder", null);
|
||||
this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
|
||||
this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
|
||||
|
||||
// Debug Settings
|
||||
this.ensureDefault("debug", false);
|
||||
this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
|
||||
|
||||
// Event Handlers
|
||||
this.settings.return_upload_start_handler = this.returnUploadStart;
|
||||
this.ensureDefault("swfupload_loaded_handler", null);
|
||||
this.ensureDefault("file_dialog_start_handler", null);
|
||||
this.ensureDefault("file_queued_handler", null);
|
||||
this.ensureDefault("file_queue_error_handler", null);
|
||||
this.ensureDefault("file_dialog_complete_handler", null);
|
||||
|
||||
this.ensureDefault("upload_start_handler", null);
|
||||
this.ensureDefault("upload_progress_handler", null);
|
||||
this.ensureDefault("upload_error_handler", null);
|
||||
this.ensureDefault("upload_success_handler", null);
|
||||
this.ensureDefault("upload_complete_handler", null);
|
||||
|
||||
this.ensureDefault("debug_handler", this.debugMessage);
|
||||
|
||||
this.ensureDefault("custom_settings", {});
|
||||
|
||||
// Other settings
|
||||
this.customSettings = this.settings.custom_settings;
|
||||
|
||||
// Update the flash url if needed
|
||||
if (!!this.settings.prevent_swf_caching) {
|
||||
this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
|
||||
}
|
||||
|
||||
if (!this.settings.preserve_relative_urls) {
|
||||
//this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url); // Don't need to do this one since flash doesn't look at it
|
||||
this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
|
||||
this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
|
||||
}
|
||||
|
||||
delete this.ensureDefault;
|
||||
};
|
||||
|
||||
// Private: loadFlash replaces the button_placeholder element with the flash movie.
|
||||
SWFUpload.prototype.loadFlash = function () {
|
||||
var targetElement, tempParent;
|
||||
|
||||
// Make sure an element with the ID we are going to use doesn't already exist
|
||||
if (document.getElementById(this.movieName) !== null) {
|
||||
throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
|
||||
}
|
||||
|
||||
// Get the element where we will be placing the flash movie
|
||||
targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
|
||||
|
||||
if (targetElement == undefined) {
|
||||
throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
|
||||
}
|
||||
|
||||
// Append the container and load the flash
|
||||
tempParent = document.createElement("div");
|
||||
tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
|
||||
targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
|
||||
|
||||
// Fix IE Flash/Form bug
|
||||
if (window[this.movieName] == undefined) {
|
||||
window[this.movieName] = this.getMovieElement();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Private: getFlashHTML generates the object tag needed to embed the flash in to the document
|
||||
SWFUpload.prototype.getFlashHTML = function () {
|
||||
// Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
|
||||
return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
|
||||
'<param name="wmode" value="', this.settings.button_window_mode, '" />',
|
||||
'<param name="movie" value="', this.settings.flash_url, '" />',
|
||||
'<param name="quality" value="high" />',
|
||||
'<param name="menu" value="false" />',
|
||||
'<param name="allowScriptAccess" value="always" />',
|
||||
'<param name="flashvars" value="' + this.getFlashVars() + '" />',
|
||||
'</object>'].join("");
|
||||
};
|
||||
|
||||
// Private: getFlashVars builds the parameter string that will be passed
|
||||
// to flash in the flashvars param.
|
||||
SWFUpload.prototype.getFlashVars = function () {
|
||||
// Build a string from the post param object
|
||||
var paramString = this.buildParamString();
|
||||
var httpSuccessString = this.settings.http_success.join(",");
|
||||
|
||||
// Build the parameter string
|
||||
return ["movieName=", encodeURIComponent(this.movieName),
|
||||
"&uploadURL=", encodeURIComponent(this.settings.upload_url),
|
||||
"&useQueryString=", encodeURIComponent(this.settings.use_query_string),
|
||||
"&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
|
||||
"&httpSuccess=", encodeURIComponent(httpSuccessString),
|
||||
"&assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
|
||||
"&params=", encodeURIComponent(paramString),
|
||||
"&filePostName=", encodeURIComponent(this.settings.file_post_name),
|
||||
"&fileTypes=", encodeURIComponent(this.settings.file_types),
|
||||
"&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
|
||||
"&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
|
||||
"&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
|
||||
"&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
|
||||
"&debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
|
||||
"&buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
|
||||
"&buttonWidth=", encodeURIComponent(this.settings.button_width),
|
||||
"&buttonHeight=", encodeURIComponent(this.settings.button_height),
|
||||
"&buttonText=", encodeURIComponent(this.settings.button_text),
|
||||
"&buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
|
||||
"&buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
|
||||
"&buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
|
||||
"&buttonAction=", encodeURIComponent(this.settings.button_action),
|
||||
"&buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
|
||||
"&buttonCursor=", encodeURIComponent(this.settings.button_cursor)
|
||||
].join("");
|
||||
};
|
||||
|
||||
// Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
|
||||
// The element is cached after the first lookup
|
||||
SWFUpload.prototype.getMovieElement = function () {
|
||||
if (this.movieElement == undefined) {
|
||||
this.movieElement = document.getElementById(this.movieName);
|
||||
}
|
||||
|
||||
if (this.movieElement === null) {
|
||||
throw "Could not find Flash element";
|
||||
}
|
||||
|
||||
return this.movieElement;
|
||||
};
|
||||
|
||||
// Private: buildParamString takes the name/value pairs in the post_params setting object
|
||||
// and joins them up in to a string formatted "name=value&name=value"
|
||||
SWFUpload.prototype.buildParamString = function () {
|
||||
var postParams = this.settings.post_params;
|
||||
var paramStringPairs = [];
|
||||
|
||||
if (typeof(postParams) === "object") {
|
||||
for (var name in postParams) {
|
||||
if (postParams.hasOwnProperty(name)) {
|
||||
paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return paramStringPairs.join("&");
|
||||
};
|
||||
|
||||
// Public: Used to remove a SWFUpload instance from the page. This method strives to remove
|
||||
// all references to the SWF, and other objects so memory is properly freed.
|
||||
// Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
|
||||
// Credits: Major improvements provided by steffen
|
||||
SWFUpload.prototype.destroy = function () {
|
||||
try {
|
||||
// Make sure Flash is done before we try to remove it
|
||||
this.cancelUpload(null, false);
|
||||
|
||||
|
||||
// Remove the SWFUpload DOM nodes
|
||||
var movieElement = null;
|
||||
movieElement = this.getMovieElement();
|
||||
|
||||
if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
|
||||
// Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround)
|
||||
for (var i in movieElement) {
|
||||
try {
|
||||
if (typeof(movieElement[i]) === "function") {
|
||||
movieElement[i] = null;
|
||||
}
|
||||
} catch (ex1) {}
|
||||
}
|
||||
|
||||
// Remove the Movie Element from the page
|
||||
try {
|
||||
movieElement.parentNode.removeChild(movieElement);
|
||||
} catch (ex) {}
|
||||
}
|
||||
|
||||
// Remove IE form fix reference
|
||||
window[this.movieName] = null;
|
||||
|
||||
// Destroy other references
|
||||
SWFUpload.instances[this.movieName] = null;
|
||||
delete SWFUpload.instances[this.movieName];
|
||||
|
||||
this.movieElement = null;
|
||||
this.settings = null;
|
||||
this.customSettings = null;
|
||||
this.eventQueue = null;
|
||||
this.movieName = null;
|
||||
|
||||
|
||||
return true;
|
||||
} catch (ex2) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Public: displayDebugInfo prints out settings and configuration
|
||||
// information about this SWFUpload instance.
|
||||
// This function (and any references to it) can be deleted when placing
|
||||
// SWFUpload in production.
|
||||
SWFUpload.prototype.displayDebugInfo = function () {
|
||||
this.debug(
|
||||
[
|
||||
"---SWFUpload Instance Info---\n",
|
||||
"Version: ", SWFUpload.version, "\n",
|
||||
"Movie Name: ", this.movieName, "\n",
|
||||
"Settings:\n",
|
||||
"\t", "upload_url: ", this.settings.upload_url, "\n",
|
||||
"\t", "flash_url: ", this.settings.flash_url, "\n",
|
||||
"\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
|
||||
"\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
|
||||
"\t", "http_success: ", this.settings.http_success.join(", "), "\n",
|
||||
"\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n",
|
||||
"\t", "file_post_name: ", this.settings.file_post_name, "\n",
|
||||
"\t", "post_params: ", this.settings.post_params.toString(), "\n",
|
||||
"\t", "file_types: ", this.settings.file_types, "\n",
|
||||
"\t", "file_types_description: ", this.settings.file_types_description, "\n",
|
||||
"\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
|
||||
"\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
|
||||
"\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
|
||||
"\t", "debug: ", this.settings.debug.toString(), "\n",
|
||||
|
||||
"\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
|
||||
|
||||
"\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
|
||||
"\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
|
||||
"\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
|
||||
"\t", "button_width: ", this.settings.button_width.toString(), "\n",
|
||||
"\t", "button_height: ", this.settings.button_height.toString(), "\n",
|
||||
"\t", "button_text: ", this.settings.button_text.toString(), "\n",
|
||||
"\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
|
||||
"\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
|
||||
"\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
|
||||
"\t", "button_action: ", this.settings.button_action.toString(), "\n",
|
||||
"\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
|
||||
|
||||
"\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
|
||||
"Event Handlers:\n",
|
||||
"\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
|
||||
"\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
|
||||
"\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
|
||||
"\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
|
||||
"\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
|
||||
"\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
|
||||
"\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
|
||||
"\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
|
||||
"\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
|
||||
"\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"
|
||||
].join("")
|
||||
);
|
||||
};
|
||||
|
||||
/* Note: addSetting and getSetting are no longer used by SWFUpload but are included
|
||||
the maintain v2 API compatibility
|
||||
*/
|
||||
// Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
|
||||
SWFUpload.prototype.addSetting = function (name, value, default_value) {
|
||||
if (value == undefined) {
|
||||
return (this.settings[name] = default_value);
|
||||
} else {
|
||||
return (this.settings[name] = value);
|
||||
}
|
||||
};
|
||||
|
||||
// Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
|
||||
SWFUpload.prototype.getSetting = function (name) {
|
||||
if (this.settings[name] != undefined) {
|
||||
return this.settings[name];
|
||||
}
|
||||
|
||||
return "";
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Private: callFlash handles function calls made to the Flash element.
|
||||
// Calls are made with a setTimeout for some functions to work around
|
||||
// bugs in the ExternalInterface library.
|
||||
SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
|
||||
argumentArray = argumentArray || [];
|
||||
|
||||
var movieElement = this.getMovieElement();
|
||||
var returnValue, returnString;
|
||||
|
||||
// Flash's method if calling ExternalInterface methods (code adapted from MooTools).
|
||||
try {
|
||||
returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
|
||||
returnValue = eval(returnString);
|
||||
} catch (ex) {
|
||||
throw "Call to " + functionName + " failed";
|
||||
}
|
||||
|
||||
// Unescape file post param values
|
||||
if (returnValue != undefined && typeof returnValue.post === "object") {
|
||||
returnValue = this.unescapeFilePostParams(returnValue);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
};
|
||||
|
||||
/* *****************************
|
||||
-- Flash control methods --
|
||||
Your UI should use these
|
||||
to operate SWFUpload
|
||||
***************************** */
|
||||
|
||||
// WARNING: this function does not work in Flash Player 10
|
||||
// Public: selectFile causes a File Selection Dialog window to appear. This
|
||||
// dialog only allows 1 file to be selected.
|
||||
SWFUpload.prototype.selectFile = function () {
|
||||
this.callFlash("SelectFile");
|
||||
};
|
||||
|
||||
// WARNING: this function does not work in Flash Player 10
|
||||
// Public: selectFiles causes a File Selection Dialog window to appear/ This
|
||||
// dialog allows the user to select any number of files
|
||||
// Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
|
||||
// If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around
|
||||
// for this bug.
|
||||
SWFUpload.prototype.selectFiles = function () {
|
||||
this.callFlash("SelectFiles");
|
||||
};
|
||||
|
||||
|
||||
// Public: startUpload starts uploading the first file in the queue unless
|
||||
// the optional parameter 'fileID' specifies the ID
|
||||
SWFUpload.prototype.startUpload = function (fileID) {
|
||||
this.callFlash("StartUpload", [fileID]);
|
||||
};
|
||||
|
||||
// Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index.
|
||||
// If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
|
||||
// If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
|
||||
SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
|
||||
if (triggerErrorEvent !== false) {
|
||||
triggerErrorEvent = true;
|
||||
}
|
||||
this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
|
||||
};
|
||||
|
||||
// Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
|
||||
// If nothing is currently uploading then nothing happens.
|
||||
SWFUpload.prototype.stopUpload = function () {
|
||||
this.callFlash("StopUpload");
|
||||
};
|
||||
|
||||
/* ************************
|
||||
* Settings methods
|
||||
* These methods change the SWFUpload settings.
|
||||
* SWFUpload settings should not be changed directly on the settings object
|
||||
* since many of the settings need to be passed to Flash in order to take
|
||||
* effect.
|
||||
* *********************** */
|
||||
|
||||
// Public: getStats gets the file statistics object.
|
||||
SWFUpload.prototype.getStats = function () {
|
||||
return this.callFlash("GetStats");
|
||||
};
|
||||
|
||||
// Public: setStats changes the SWFUpload statistics. You shouldn't need to
|
||||
// change the statistics but you can. Changing the statistics does not
|
||||
// affect SWFUpload accept for the successful_uploads count which is used
|
||||
// by the upload_limit setting to determine how many files the user may upload.
|
||||
SWFUpload.prototype.setStats = function (statsObject) {
|
||||
this.callFlash("SetStats", [statsObject]);
|
||||
};
|
||||
|
||||
// Public: getFile retrieves a File object by ID or Index. If the file is
|
||||
// not found then 'null' is returned.
|
||||
SWFUpload.prototype.getFile = function (fileID) {
|
||||
if (typeof(fileID) === "number") {
|
||||
return this.callFlash("GetFileByIndex", [fileID]);
|
||||
} else {
|
||||
return this.callFlash("GetFile", [fileID]);
|
||||
}
|
||||
};
|
||||
|
||||
// Public: addFileParam sets a name/value pair that will be posted with the
|
||||
// file specified by the Files ID. If the name already exists then the
|
||||
// exiting value will be overwritten.
|
||||
SWFUpload.prototype.addFileParam = function (fileID, name, value) {
|
||||
return this.callFlash("AddFileParam", [fileID, name, value]);
|
||||
};
|
||||
|
||||
// Public: removeFileParam removes a previously set (by addFileParam) name/value
|
||||
// pair from the specified file.
|
||||
SWFUpload.prototype.removeFileParam = function (fileID, name) {
|
||||
this.callFlash("RemoveFileParam", [fileID, name]);
|
||||
};
|
||||
|
||||
// Public: setUploadUrl changes the upload_url setting.
|
||||
SWFUpload.prototype.setUploadURL = function (url) {
|
||||
this.settings.upload_url = url.toString();
|
||||
this.callFlash("SetUploadURL", [url]);
|
||||
};
|
||||
|
||||
// Public: setPostParams changes the post_params setting
|
||||
SWFUpload.prototype.setPostParams = function (paramsObject) {
|
||||
this.settings.post_params = paramsObject;
|
||||
this.callFlash("SetPostParams", [paramsObject]);
|
||||
};
|
||||
|
||||
// Public: addPostParam adds post name/value pair. Each name can have only one value.
|
||||
SWFUpload.prototype.addPostParam = function (name, value) {
|
||||
this.settings.post_params[name] = value;
|
||||
this.callFlash("SetPostParams", [this.settings.post_params]);
|
||||
};
|
||||
|
||||
// Public: removePostParam deletes post name/value pair.
|
||||
SWFUpload.prototype.removePostParam = function (name) {
|
||||
delete this.settings.post_params[name];
|
||||
this.callFlash("SetPostParams", [this.settings.post_params]);
|
||||
};
|
||||
|
||||
// Public: setFileTypes changes the file_types setting and the file_types_description setting
|
||||
SWFUpload.prototype.setFileTypes = function (types, description) {
|
||||
this.settings.file_types = types;
|
||||
this.settings.file_types_description = description;
|
||||
this.callFlash("SetFileTypes", [types, description]);
|
||||
};
|
||||
|
||||
// Public: setFileSizeLimit changes the file_size_limit setting
|
||||
SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
|
||||
this.settings.file_size_limit = fileSizeLimit;
|
||||
this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
|
||||
};
|
||||
|
||||
// Public: setFileUploadLimit changes the file_upload_limit setting
|
||||
SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
|
||||
this.settings.file_upload_limit = fileUploadLimit;
|
||||
this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
|
||||
};
|
||||
|
||||
// Public: setFileQueueLimit changes the file_queue_limit setting
|
||||
SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
|
||||
this.settings.file_queue_limit = fileQueueLimit;
|
||||
this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
|
||||
};
|
||||
|
||||
// Public: setFilePostName changes the file_post_name setting
|
||||
SWFUpload.prototype.setFilePostName = function (filePostName) {
|
||||
this.settings.file_post_name = filePostName;
|
||||
this.callFlash("SetFilePostName", [filePostName]);
|
||||
};
|
||||
|
||||
// Public: setUseQueryString changes the use_query_string setting
|
||||
SWFUpload.prototype.setUseQueryString = function (useQueryString) {
|
||||
this.settings.use_query_string = useQueryString;
|
||||
this.callFlash("SetUseQueryString", [useQueryString]);
|
||||
};
|
||||
|
||||
// Public: setRequeueOnError changes the requeue_on_error setting
|
||||
SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
|
||||
this.settings.requeue_on_error = requeueOnError;
|
||||
this.callFlash("SetRequeueOnError", [requeueOnError]);
|
||||
};
|
||||
|
||||
// Public: setHTTPSuccess changes the http_success setting
|
||||
SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
|
||||
if (typeof http_status_codes === "string") {
|
||||
http_status_codes = http_status_codes.replace(" ", "").split(",");
|
||||
}
|
||||
|
||||
this.settings.http_success = http_status_codes;
|
||||
this.callFlash("SetHTTPSuccess", [http_status_codes]);
|
||||
};
|
||||
|
||||
// Public: setHTTPSuccess changes the http_success setting
|
||||
SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
|
||||
this.settings.assume_success_timeout = timeout_seconds;
|
||||
this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
|
||||
};
|
||||
|
||||
// Public: setDebugEnabled changes the debug_enabled setting
|
||||
SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
|
||||
this.settings.debug_enabled = debugEnabled;
|
||||
this.callFlash("SetDebugEnabled", [debugEnabled]);
|
||||
};
|
||||
|
||||
// Public: setButtonImageURL loads a button image sprite
|
||||
SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
|
||||
if (buttonImageURL == undefined) {
|
||||
buttonImageURL = "";
|
||||
}
|
||||
|
||||
this.settings.button_image_url = buttonImageURL;
|
||||
this.callFlash("SetButtonImageURL", [buttonImageURL]);
|
||||
};
|
||||
|
||||
// Public: setButtonDimensions resizes the Flash Movie and button
|
||||
SWFUpload.prototype.setButtonDimensions = function (width, height) {
|
||||
this.settings.button_width = width;
|
||||
this.settings.button_height = height;
|
||||
|
||||
var movie = this.getMovieElement();
|
||||
if (movie != undefined) {
|
||||
movie.style.width = width + "px";
|
||||
movie.style.height = height + "px";
|
||||
}
|
||||
|
||||
this.callFlash("SetButtonDimensions", [width, height]);
|
||||
};
|
||||
// Public: setButtonText Changes the text overlaid on the button
|
||||
SWFUpload.prototype.setButtonText = function (html) {
|
||||
this.settings.button_text = html;
|
||||
this.callFlash("SetButtonText", [html]);
|
||||
};
|
||||
// Public: setButtonTextPadding changes the top and left padding of the text overlay
|
||||
SWFUpload.prototype.setButtonTextPadding = function (left, top) {
|
||||
this.settings.button_text_top_padding = top;
|
||||
this.settings.button_text_left_padding = left;
|
||||
this.callFlash("SetButtonTextPadding", [left, top]);
|
||||
};
|
||||
|
||||
// Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
|
||||
SWFUpload.prototype.setButtonTextStyle = function (css) {
|
||||
this.settings.button_text_style = css;
|
||||
this.callFlash("SetButtonTextStyle", [css]);
|
||||
};
|
||||
// Public: setButtonDisabled disables/enables the button
|
||||
SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
|
||||
this.settings.button_disabled = isDisabled;
|
||||
this.callFlash("SetButtonDisabled", [isDisabled]);
|
||||
};
|
||||
// Public: setButtonAction sets the action that occurs when the button is clicked
|
||||
SWFUpload.prototype.setButtonAction = function (buttonAction) {
|
||||
this.settings.button_action = buttonAction;
|
||||
this.callFlash("SetButtonAction", [buttonAction]);
|
||||
};
|
||||
|
||||
// Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
|
||||
SWFUpload.prototype.setButtonCursor = function (cursor) {
|
||||
this.settings.button_cursor = cursor;
|
||||
this.callFlash("SetButtonCursor", [cursor]);
|
||||
};
|
||||
|
||||
/* *******************************
|
||||
Flash Event Interfaces
|
||||
These functions are used by Flash to trigger the various
|
||||
events.
|
||||
|
||||
All these functions a Private.
|
||||
|
||||
Because the ExternalInterface library is buggy the event calls
|
||||
are added to a queue and the queue then executed by a setTimeout.
|
||||
This ensures that events are executed in a determinate order and that
|
||||
the ExternalInterface bugs are avoided.
|
||||
******************************* */
|
||||
|
||||
SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
|
||||
// Warning: Don't call this.debug inside here or you'll create an infinite loop
|
||||
|
||||
if (argumentArray == undefined) {
|
||||
argumentArray = [];
|
||||
} else if (!(argumentArray instanceof Array)) {
|
||||
argumentArray = [argumentArray];
|
||||
}
|
||||
|
||||
var self = this;
|
||||
if (typeof this.settings[handlerName] === "function") {
|
||||
// Queue the event
|
||||
this.eventQueue.push(function () {
|
||||
this.settings[handlerName].apply(this, argumentArray);
|
||||
});
|
||||
|
||||
// Execute the next queued event
|
||||
setTimeout(function () {
|
||||
self.executeNextEvent();
|
||||
}, 0);
|
||||
|
||||
} else if (this.settings[handlerName] !== null) {
|
||||
throw "Event handler " + handlerName + " is unknown or is not a function";
|
||||
}
|
||||
};
|
||||
|
||||
// Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout
|
||||
// we must queue them in order to garentee that they are executed in order.
|
||||
SWFUpload.prototype.executeNextEvent = function () {
|
||||
// Warning: Don't call this.debug inside here or you'll create an infinite loop
|
||||
|
||||
var f = this.eventQueue ? this.eventQueue.shift() : null;
|
||||
if (typeof(f) === "function") {
|
||||
f.apply(this);
|
||||
}
|
||||
};
|
||||
|
||||
// Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
|
||||
// properties that contain characters that are not valid for JavaScript identifiers. To work around this
|
||||
// the Flash Component escapes the parameter names and we must unescape again before passing them along.
|
||||
SWFUpload.prototype.unescapeFilePostParams = function (file) {
|
||||
var reg = /[$]([0-9a-f]{4})/i;
|
||||
var unescapedPost = {};
|
||||
var uk;
|
||||
|
||||
if (file != undefined) {
|
||||
for (var k in file.post) {
|
||||
if (file.post.hasOwnProperty(k)) {
|
||||
uk = k;
|
||||
var match;
|
||||
while ((match = reg.exec(uk)) !== null) {
|
||||
uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
|
||||
}
|
||||
unescapedPost[uk] = file.post[k];
|
||||
}
|
||||
}
|
||||
|
||||
file.post = unescapedPost;
|
||||
}
|
||||
|
||||
return file;
|
||||
};
|
||||
|
||||
// Private: Called by Flash to see if JS can call in to Flash (test if External Interface is working)
|
||||
SWFUpload.prototype.testExternalInterface = function () {
|
||||
try {
|
||||
return this.callFlash("TestExternalInterface");
|
||||
} catch (ex) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Private: This event is called by Flash when it has finished loading. Don't modify this.
|
||||
// Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded.
|
||||
SWFUpload.prototype.flashReady = function () {
|
||||
// Check that the movie element is loaded correctly with its ExternalInterface methods defined
|
||||
var movieElement = this.getMovieElement();
|
||||
|
||||
if (!movieElement) {
|
||||
this.debug("Flash called back ready but the flash movie can't be found.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.cleanUp(movieElement);
|
||||
|
||||
this.queueEvent("swfupload_loaded_handler");
|
||||
};
|
||||
|
||||
// Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.
|
||||
// This function is called by Flash each time the ExternalInterface functions are created.
|
||||
SWFUpload.prototype.cleanUp = function (movieElement) {
|
||||
// Pro-actively unhook all the Flash functions
|
||||
try {
|
||||
if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
|
||||
this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
|
||||
for (var key in movieElement) {
|
||||
try {
|
||||
if (typeof(movieElement[key]) === "function") {
|
||||
movieElement[key] = null;
|
||||
}
|
||||
} catch (ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ex1) {
|
||||
|
||||
}
|
||||
|
||||
// Fix Flashes own cleanup code so if the SWFMovie was removed from the page
|
||||
// it doesn't display errors.
|
||||
window["__flash__removeCallback"] = function (instance, name) {
|
||||
try {
|
||||
if (instance) {
|
||||
instance[name] = null;
|
||||
}
|
||||
} catch (flashEx) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* This is a chance to do something before the browse window opens */
|
||||
SWFUpload.prototype.fileDialogStart = function () {
|
||||
this.queueEvent("file_dialog_start_handler");
|
||||
};
|
||||
|
||||
|
||||
/* Called when a file is successfully added to the queue. */
|
||||
SWFUpload.prototype.fileQueued = function (file) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("file_queued_handler", file);
|
||||
};
|
||||
|
||||
|
||||
/* Handle errors that occur when an attempt to queue a file fails. */
|
||||
SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
|
||||
};
|
||||
|
||||
/* Called after the file dialog has closed and the selected files have been queued.
|
||||
You could call startUpload here if you want the queued files to begin uploading immediately. */
|
||||
SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
|
||||
this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.uploadStart = function (file) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("return_upload_start_handler", file);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.returnUploadStart = function (file) {
|
||||
var returnValue;
|
||||
if (typeof this.settings.upload_start_handler === "function") {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
returnValue = this.settings.upload_start_handler.call(this, file);
|
||||
} else if (this.settings.upload_start_handler != undefined) {
|
||||
throw "upload_start_handler must be a function";
|
||||
}
|
||||
|
||||
// Convert undefined to true so if nothing is returned from the upload_start_handler it is
|
||||
// interpretted as 'true'.
|
||||
if (returnValue === undefined) {
|
||||
returnValue = true;
|
||||
}
|
||||
|
||||
returnValue = !!returnValue;
|
||||
|
||||
this.callFlash("ReturnUploadStart", [returnValue]);
|
||||
};
|
||||
|
||||
|
||||
|
||||
SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.uploadError = function (file, errorCode, message) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("upload_error_handler", [file, errorCode, message]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
|
||||
};
|
||||
|
||||
SWFUpload.prototype.uploadComplete = function (file) {
|
||||
file = this.unescapeFilePostParams(file);
|
||||
this.queueEvent("upload_complete_handler", file);
|
||||
};
|
||||
|
||||
/* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
|
||||
internal debug console. You can override this event and have messages written where you want. */
|
||||
SWFUpload.prototype.debug = function (message) {
|
||||
this.queueEvent("debug_handler", message);
|
||||
};
|
||||
|
||||
|
||||
/* **********************************
|
||||
Debug Console
|
||||
The debug console is a self contained, in page location
|
||||
for debug message to be sent. The Debug Console adds
|
||||
itself to the body if necessary.
|
||||
|
||||
The console is automatically scrolled as messages appear.
|
||||
|
||||
If you are using your own debug handler or when you deploy to production and
|
||||
have debug disabled you can remove these functions to reduce the file size
|
||||
and complexity.
|
||||
********************************** */
|
||||
|
||||
// Private: debugMessage is the default debug_handler. If you want to print debug messages
|
||||
// call the debug() function. When overriding the function your own function should
|
||||
// check to see if the debug setting is true before outputting debug information.
|
||||
SWFUpload.prototype.debugMessage = function (message) {
|
||||
if (this.settings.debug) {
|
||||
var exceptionMessage, exceptionValues = [];
|
||||
|
||||
// Check for an exception object and print it nicely
|
||||
if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
|
||||
for (var key in message) {
|
||||
if (message.hasOwnProperty(key)) {
|
||||
exceptionValues.push(key + ": " + message[key]);
|
||||
}
|
||||
}
|
||||
exceptionMessage = exceptionValues.join("\n") || "";
|
||||
exceptionValues = exceptionMessage.split("\n");
|
||||
exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
|
||||
SWFUpload.Console.writeLine(exceptionMessage);
|
||||
} else {
|
||||
SWFUpload.Console.writeLine(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
SWFUpload.Console = {};
|
||||
SWFUpload.Console.writeLine = function (message) {
|
||||
var console, documentForm;
|
||||
|
||||
try {
|
||||
console = document.getElementById("SWFUpload_Console");
|
||||
|
||||
if (!console) {
|
||||
documentForm = document.createElement("form");
|
||||
document.getElementsByTagName("body")[0].appendChild(documentForm);
|
||||
|
||||
console = document.createElement("textarea");
|
||||
console.id = "SWFUpload_Console";
|
||||
console.style.fontFamily = "monospace";
|
||||
console.setAttribute("wrap", "off");
|
||||
console.wrap = "off";
|
||||
console.style.overflow = "auto";
|
||||
console.style.width = "700px";
|
||||
console.style.height = "350px";
|
||||
console.style.margin = "5px";
|
||||
documentForm.appendChild(console);
|
||||
}
|
||||
|
||||
console.value += message + "\n";
|
||||
|
||||
console.scrollTop = console.scrollHeight - console.clientHeight;
|
||||
} catch (ex) {
|
||||
alert("Exception: " + ex.name + " Message: " + ex.message);
|
||||
}
|
||||
};
|
||||
BIN
web/App_Script/swfupload/swfupload.swf
Normal file
BIN
web/App_Script/swfupload/swfupload.swf
Normal file
Binary file not shown.
BIN
web/App_Script/swfupload/swfuploadbutton.swf
Normal file
BIN
web/App_Script/swfupload/swfuploadbutton.swf
Normal file
Binary file not shown.
Reference in New Issue
Block a user