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

     简单示例下载

  • 相关阅读:
    魅力惠_百度百科
    新奢侈主义_百度百科
    FastSocket学习笔记~再说客户端与服务端的组成
    在线支付文章索引(支付宝_微信_银联)
    微信JSApi支付~微信支付代理模式的实现(原创)
    爱上MVC~ajax调用分部视图session超时页面跳转问题
    C#~异步编程再续~await与async引起的w3wp.exe崩溃-问题友好的解决
    poj-3895-Cycles of Lanes 简单DFS
    How to search a table in a store proc and open the store proc
    Github-Client(ANDROID)开源之旅(四) ------ 简介Roboguice
  • 原文地址:https://www.cnblogs.com/ringwang/p/2220208.html
Copyright © 2011-2022 走看看