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");   
                }  
            }

     简单示例下载

  • 相关阅读:
    Spring 让 LOB 数据操作变得简单易行
    让Apache Shiro保护你的应用
    MongoDB、Java及ORM
    Spring 的优秀工具类盘点,第 1 部分: 文件资源操作和 Web 相关工具类
    Spring 的优秀工具类盘点,第 2 部分: 特殊字符转义和方法入参检测工具类
    SpringMVC:上传与下载
    Web数据挖掘在电子商务中的应用
    Mongodb快速入门之使用Java操作Mongodb
    Mongodb数据库入门之Spring Mongodb
    基于综合兴趣度的协同过滤推荐算法
  • 原文地址:https://www.cnblogs.com/ringwang/p/2220208.html
Copyright © 2011-2022 走看看