flashedit.aspx
来源:互联网 发布:听录音打字软件 编辑:程序博客网 时间:2024/05/17 07:40
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FlashEdit.aspx.cs" Inherits="JinRi.Ticket.Web.Application.FlashEdit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>编辑Flash图片信息</title>
<style type="text/css">
.btn0
{
height: 26px;
}
.tdprize
{
text-align: right;
}
</style>
<script type="text/javascript" src="/Js/swfupload.js" language="javascript"></script>
</head>
<body style="width: 96%;">
<form id="form1" runat="server">
<div>
<asp:HiddenField ID="hdfID" runat="server" Value="0" />
<asp:HiddenField ID="hdfPid" runat="server" />
<table cellspacing="0" class="bg23" cellpadding="0" align="center" border="0">
<tr style="text-align:left;">
<td>
编辑图片信息
</td>
</tr>
<tr>
<td align="right" style="margin-right: 20px; padding-right: 80px;">
<font class="font3">图片预览</font>
</td>
</tr>
</table>
<table cellspacing="0" width="798px" class="ttb36" cellpadding="0" align="center"
border="0">
<tr>
<td class="font3 tdprize" style="width:30%">
图片说明:
</td>
<td class="font3">
<asp:TextBox ID="txtDes" AutoCompleteType="Disabled" runat="server" MaxLength="100"></asp:TextBox>
</td>
<td rowspan="5">
<div style="float: left; width: 120px; padding-left: 8px; padding-top: 5px; margin-right:10px;">
<a style="display: block; width: 120px; height: 120px; border: 1px solid #ccc;" title="产品图片">
<img runat="server" alt="" id="productImg" width="120" height="120" onerror="this.src='/Images/nopic.jpg';"
style="border: 2px solid #fff;" border="0" src="/Images/nopic.jpg" /></a>
</div>
</td>
</tr>
<tr>
<td class="font3 tdprize">
上传图片:
</td>
<td class="font3">
<%--<input id="txtFile" runat="server" type="file" contenteditable="false"
name="txtFile" onchange="onImagechange()" />--%>
<input type="text" id="txtSWFServerPath" readonly="readonly" runat="server"/>
<span id="spanSWFUploadButton"></span><label id="lblUploadMessage" style="display:none">文件上传中……</label>
<font color="#ff0000">*</font>
<asp:TextBox ID="hidPhoto" Style="display: none;" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="font3 tdprize">
链接地址:
</td>
<td class="font3">
<asp:TextBox ID="txtUrl" AutoCompleteType="Disabled" runat="server" ></asp:TextBox>
</td>
</tr>
<tr style="padding-bottom: 10px;">
<td align="center" valign="bottom" style="height: 40px; text-align: center" colspan="2"
class="font3">
<asp:Button ID="btnSave" CssClass="btn0" runat="server" Text="保 存" OnClick="btnSave_Click"
OnClientClick="return checkForm();" />
<input id="btnBack" type="button" class="btn0" value="返 回" onclick="window.history.go(-1)" />
</td>
<td align="center" valign="bottom" style="height: 40px; text-align: center" class="font3">
</td>
</tr>
</table>
</div>
</form>
<script type="text/javascript" language="javascript">
var IsExe = true;
//创建一个SWF上传组件对象
var swfu = new SWFUpload({
//debug: true,
upload_url: "/Ajax/FileUpload.ashx",
flash_url: "/SWF/swfupload.swf",
button_image_url: "/Images/read.png",
button_width: '60',
button_height: '20',
file_types: '*.gif;*.jpg;*.png',
file_size_limit: "1 MB",
button_placeholder_id: "spanSWFUploadButton",
button_window_mode: 'transparent',
file_dialog_complete_handler: fileDialogComplete,
upload_success_handler: uploadSuccess,
//upload_complete_handler: $empty,
upload_error_handler: uploadError,
file_dialog_start_handler: fileDialogStart,
file_queue_error_handler: function(file, code, msg) {
var text;
switch (code) {
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
text = '文件大小超过限制!';
IsExe = false;
break;
default:
text = msg;
break;
}
alert(text);
return false;
}
});
//选择文件框启动事件
function fileDialogStart() {
document.getElementById("lblUploadMessage").style.display = "none";
document.getElementById("txtSWFServerPath").value = "";
IsExe = true;
}
//选择文件结束事件
function fileDialogComplete(numFilesSelected, numFilesQueued) {
try {
if (numFilesQueued == 1) {
document.getElementById("lblUploadMessage").style.display = "";
swfu.startUpload();
} else if (numFilesQueued == 0) {
} else {
if (IsExe) {
alert('很抱歉,不能上传多个文件!');
}
}
} catch (ex) {
alert(ex);
}
}
//上传成功事件
function uploadSuccess(file, data) {
//alert(file.name + " # " + data);
document.getElementById("txtSWFServerPath").value = data;
document.getElementById("lblUploadMessage").innerText = "上传成功!";
}
//上传失败事件
function uploadError(file, errorCode, message) {
document.getElementById("lblUploadMessage").innerText = "上传失败!";
}
</script>
<script type="text/javascript" language="javascript">
function check_validate1(value) { //定义正则表达式部分
var reg = /^/d+$/;
if (value.constructor === String) {
var re = value.match(reg);
return true;
}
return false;
}
function checkForm() {
var photo = document.getElementById("txtSWFServerPath");
var url=document.getElementById("txtUrl");
var patn = //.jpg$|/.bmp$|/.jpeg$|/.gif$|/.png$/;
var id=document.getElementById("hdfID").value;
var reg = /^/d+$/;
var reghttp=/^http/://///w+(/./w+)*(///w+)*(/?/w+=/w*(&/w+=/w*)*)?$/g;
if(id==null||id==0){
if (isEmpty("txtSWFServerPath")) {
alert("请选择图片!");
photo.focus();
return false;
}
}
if(url.value.trim() == ""){
alert("请输入URL地址!");
url.focus();
return false;
}else{
if(reghttp.test(url.value)){
}else{
alert("请输入正确的URL地址!");
url.focus();
return false;
}
}
return confirm("你确定要保存吗?");
}
</script>
</body>
</html>
FileUpload.ashx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.IO;
namespace JinRi.Ticket.Web.Ajax
{
/// <summary>
/// $codebehindclassname$ 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class FileUpload : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
HttpPostedFile file = context.Request.Files[0];
if (file == null) return;
string extendname = Path.GetExtension(file.FileName).ToLower();
///只允许上传
//if (extendname != ".jpg" || extendname != ".gif" || extendname != ".png") return;
string phydir = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "File";
string month = DateTime.Now.ToString("yyyy-MM");
string path = phydir + "//" + month;
Random r = new Random();
string filename = DateTime.Now.ToString("yyMMddHHmmssff") + r.Next(0, 100).ToString("00");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string savePath = path + "//" + filename + extendname;
file.SaveAs(savePath);
context.Response.Write("HTTP://" + context.Request.Url.Host + "//File//" + filename + extendname);
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Text;
namespace JinRi.Ticket.Web.Application
{
public partial class FlashEdit : AppCode.BasePage
{
private int errMsg = -1;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitPageValues();
}
}
#region InitPageValues
private void InitPageValues()
{
string Id = Common.Request.GetString("ID");
if (!string.IsNullOrEmpty(Id))
{
Entity.FlashInfo flash = new Ticket.Entity.FlashInfo();
flash.Id = Convert.ToInt32(Id);
hdfID.Value = flash.Id.ToString();
flash = Logic.FlashLogic.GetModel(flash, out errMsg);
base.ShowErr(errMsg);
//this.txtSpeed.Text = flash.ImgSpeed.ToString();
this.txtUrl.Text = flash.ImgUrl.ToString();
this.txtDes.Text = flash.ImgDescription.ToString();
this.productImg.Src = flash.ImgName;
hdfPid.Value = Common.Request.GetString("pid");
}
}
#endregion
#region GetPageValues
private Entity.FlashInfo GetPageValues()
{
Entity.FlashInfo flash = new Ticket.Entity.FlashInfo();
if (txtDes.Text != "")
{
flash.ImgDescription = txtDes.Text.Trim();
}
flash.ImgSpeed =4000;
if (txtUrl.Text != "")
{
flash.ImgUrl = txtUrl.Text.Trim();
}
string Id = hdfID.Value;
if (!string.IsNullOrEmpty(Id))
{
flash.Id = Convert.ToInt32(Id);
if (!string.IsNullOrEmpty(txtSWFServerPath.Value.Trim()))
{
string fullpath = txtSWFServerPath.Value;
StringBuilder url = new StringBuilder("http:////"+Request.Url.Host+":"+Request.Url.Port+"//File//" + DateTime.Now.Year.ToString() + '-');
//发布后用 不加端口号
// StringBuilder url = new StringBuilder("http:////" + Request.Url.Host + "//File//" + DateTime.Now.Year.ToString() + '-');
if (DateTime.Now.Month < 10)
{
url.Append('0' + DateTime.Now.Month.ToString());
}
else
{
url.Append(DateTime.Now.Month.ToString());
}
url.Append("//" + fullpath.Substring(fullpath.LastIndexOf("//") + 1));
flash.ImgName = url.ToString();
}
else
{
flash.ImgName = Logic.FlashLogic.GetModel(flash, out errMsg).ImgName;
}
}
return flash;
}
#endregion
#region Event
protected void btnSave_Click(object sender, EventArgs e)
{
Entity.FlashInfo flash = GetPageValues();
string url = "/Application/FlashList.aspx?pid=" + Common.Request.GetString("pid");
string Id = hdfID.Value;
if (Id == "") Id = "0";
flash.Id= Convert.ToInt32(Id);
int result;
if (!string.IsNullOrEmpty(Id) && Id != "0")
{
result = Ticket.Logic.FlashLogic.Update(flash, out errMsg);
if (errMsg != -1)
{
ShowBox(Ticket.Entity.MessageBox.Error, "错误代码【" + errMsg + "】");
return;
}
if (result > 0)
{
base.AlertScript("恭喜您,操作成功!", "/Application/FlashList.aspx?pid=" + base.ReturnUrl);
}
else
{
base.AlertScript("很抱歉,操作失败!");
}
}
else
{
result = Logic.FlashLogic.Add(flash, out errMsg);
if (errMsg != -1)
{
ShowBox(Ticket.Entity.MessageBox.Error, "错误代码【" + errMsg + "】");
return;
}
if (result > 0)
{
base.AlertScript("恭喜您,操作成功!", "/Application/FlashList.aspx" + base.ReturnUrl);
}
else
{
base.AlertScript("很抱歉,操作失败!");
}
}
}
//获取文件路径
private string GetUploadPath(string filename)
{
string uploadPath = Page.Request.PhysicalApplicationPath + "FlashImg//";//文件路径
string filePath = uploadPath + filename;
if (!Directory.Exists(uploadPath))
{
Directory.CreateDirectory(uploadPath);
}
return filePath;
}
#endregion
}
}
- flashedit.aspx
- aspx
- upload.aspx
- ServU.aspx
- Search.aspx
- addteach aspx
- IIS ASPX
- 厌恶aspx
- Login.aspx
- products.aspx
- servu.aspx
- aspx马
- ASPX文件
- PageImage.aspx
- PageImageAccess.aspx
- PageImageSQL.aspx
- PageLoadData.aspx
- PageSaveData.aspx
- 利用div+css在GridView模版列打造可定制的ToolTip风格
- 关于 C++ primer
- UVa 10252 Common Permutation
- HyperLink用法
- 微软迅速修复零日IE漏洞
- flashedit.aspx
- SystemParametersInfo ( SPI_GETNONCLIENTMETRICS... 在VC 2008 里不能正常工作
- java上传图片到ftp
- 对于我来说,努力不一定能成功,但是不努力一定不能成功,为了那1%的成功而努力
- 6
- mke2fs 命令的用法
- java.sql.SQLException: 不能在 UTF8 和 UCS2 之间转换: failUTF8Conv
- MFC ODBC数据库编程
- php __FILE__