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

     简单示例下载

  • 相关阅读:
    9.16动手又动脑
    C#中集合的交集:Intersect问题
    LeetCode Easy: 27. Remove Element
    LeetCode Easy: 26.Remove Duplicates from Sorted Array
    LeetCode Easy: 21. Merge Two Sorted Lists
    LeetCode Easy: 20. Valid Parentheses
    LeetCode Easy: 14. Longest Common Prefix
    LeetCode Easy: 13. Roman to Integer
    LeetCode Easy: Palindrome Number
    DL: 初试 tensorflow
  • 原文地址:https://www.cnblogs.com/ringwang/p/2220208.html
Copyright © 2011-2022 走看看