修改图片上传

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

  

posted on 2016-05-02 18:23  蓝蓝的天2016  阅读(314)  评论(0编辑  收藏  举报