码迷,mamicode.com
首页 > Web开发 > 详细

修改图片上传

时间:2016-05-02 19:57:12      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

FileDialog.aspx.cs中

       if ((canEdit)&&(browserType != "folder"))
            {
                string fileSystemToken = Global.FileSystemToken.ToString();

                uploader.UseDropZone = WebConfigSettings.FileDialogEnableDragDrop;

                uploader.UploadButtonClientId = btnUpload.ClientID;
                uploader.ServiceUrl = navigationRoot
                    + "/Services/FileService.ashx?cmd=uploadfromeditor&q="
                    + Server.UrlEncode(hdnFolder.ClientID)
                    + "&t=" + fileSystemToken;

                //把返回值赋值给 txtSelection控件和hdnFileUrl控件,然后模拟点击btnSubmit按钮
                //返回值 txtSelction
                uploader.ReturnValueFormFieldClientId = txtSelection.ClientID;
                //返回值  hdnFileUrl
                uploader.ReturnValueFormFieldClientId2 = hdnFileUrl.ClientID;
                //返回值 btnSubmit
                uploader.ReturnValueFormFieldClientId3 = btnSubmit.ClientID;

jqueryFileUpload.cs中

 

     // set the return value from the upload as the value on the provided input id
            //设置返回值--txtSelection
            if (returnValueFormFieldClientId.Length > 0)
            {
                script.Append("var input = $(‘#" + returnValueFormFieldClientId + "‘); ");
                script.Append("if(input){");

                script.Append("if (data.result && $.isArray(data.result.files)) {");
                script.Append("input.val(data.result.files[0].FileUrl); ");
                script.Append("} "); //isarray
                script.Append("} ");
            }

            //add by wenjie
            //设置返回值--hdnFileUrl
            if (returnValueFormFieldClientId2.Length > 0)
            {
                script.Append("var input2 = $(‘#" + returnValueFormFieldClientId2 + "‘); ");
                script.Append("if(input2){");

                script.Append("if (data.result && $.isArray(data.result.files)) {");
                script.Append("input2.val(data.result.files[0].FileUrl); ");
                script.Append("} "); //isarray
                script.Append("} ");
            }
            //设置返回值  直接点击btnSubmit按钮
            if (returnValueFormFieldClientId3.Length > 0)
            {
                script.Append("var input3 = $(‘#" + returnValueFormFieldClientId3 + "‘); ");
                script.Append("if(input3){");               
                script.Append("input3.click(); ");
        
                script.Append("} ");
            }
   //返回值2016
        private string returnValueFormFieldClientId = string.Empty;
        /// <summary>
        /// if provided then the returnvalue from the service will be populated in this form element
        /// typical use would be a hidden field
        /// </summary>
        [Themeable(false)]
        public string ReturnValueFormFieldClientId
        {
            get { return returnValueFormFieldClientId; }
            set { returnValueFormFieldClientId = value; }
        }

        //返回值2016
        private string returnValueFormFieldClientId2 = string.Empty;
        /// <summary>
        /// if provided then the returnvalue from the service will be populated in this form element
        /// typical use would be a hidden field
        /// </summary>
        [Themeable(false)]
        public string ReturnValueFormFieldClientId2
        {
            get { return returnValueFormFieldClientId2; }
            set { returnValueFormFieldClientId2 = value; }
        }



        //返回值2016
        private string returnValueFormFieldClientId3 = string.Empty;
        /// <summary>
        /// if provided then the returnvalue from the service will be populated in this form element
        /// typical use would be a hidden field
        /// </summary>
        [Themeable(false)]
        public string ReturnValueFormFieldClientId3
        {
            get { return returnValueFormFieldClientId3; }
            set { returnValueFormFieldClientId3 = value; }
        }

 Service/FileService.ashx中

 string newFileName = DateTime.Now.ToString("yyyyMMddmmss") + Path.GetFileName(fileUploaded.FileName).ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);

  

修改图片上传

标签:

原文地址:http://www.cnblogs.com/wenjie/p/5452801.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!