zoukankan      html  css  js  c++  java
  • 带FLASH插件图片上传

    带FLASH插件图片上传
    客户端:
    <script type="text/javascript">
            $(document).ready(function()
            {
                $("#uploadify").uploadify({
                    'uploader''JS/jquery.uploadify-v2.1.0/uploadify.swf',
                    'script''UploadHandler.ashx',
                    'cancelImg''JS/jquery.uploadify-v2.1.0/cancel.png',
                    'folder''UploadFile',
                    'queueID''fileQueue',
                    'auto'false,
                    'multi'true,
                    'onComplete':function(event,queueId,fileObj,response,data)
                    {
                        //alert(response);
                        $("#testimg").attr("src",response);
                        //alert($("#testimg").attr("src"));
                    }               
                });
            });  
        </script>

    服务器端:

    public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/plain";   
                context.Response.Charset = "utf-8";   

                HttpPostedFile file = context.Request.Files["Filedata"];
                string exname = file.FileName.Substring(file.FileName.LastIndexOf('.'), 4);  //包含了点号
                string filename = file.FileName.Substring(0, file.FileName.LastIndexOf('.'));
                filename = filename + "_" + System.DateTime.Now.Second.ToString() + exname;
                string  uploadPath = 
                    HttpContext.Current.Server.MapPath(@context.Request["folder"])+"\\";  

                if (file != null)  
                {  
                   if (!Directory.Exists(uploadPath))  
                   {  
                       Directory.CreateDirectory(uploadPath);  
                   }   
                   file.SaveAs(uploadPath +  filename);  
                    //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
                   context.Response.Write(@context.Request["folder"]+"/" + filename);  
                }   
                else  
                {   
                    context.Response.Write("0");   
                }  
            }

     简单示例下载

  • 相关阅读:
    配置ASP.NET 2.0环境
    httpwatch
    自定义分页控件
    clear在CSS中的妙用
    Maximum length exceeded错误
    SQLServer数据表分区优化数据库
    游标的使用
    在Sql Server 使用系统存储过程sp_rename修改表名或列名
    SQL Server中如何备份到异机
    SQL Server 中 自定义函数 和 游标 应用的经典案例
  • 原文地址:https://www.cnblogs.com/ringwang/p/2220208.html
Copyright © 2011-2022 走看看