Пример #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string uploadResult;
            string fileName;

            ImgUploadReq entity = new ImgUploadReq();

            entity.Id   = 10;
            entity.Type = (int)ImgType.PdtSepcIcon;
            entity.File = Request.Files[0];
            Response.Write("FileName=" + Request.Files[0].FileName);
            uploadResult = ImgClient.UploadImg(entity);
            //获取上传后的返回信息
            ImgUploadRes uploadRes = XpShopJSONHelper.Deserialize <XpShop.Client.Entity.ImgUploadRes>(uploadResult);

            if (uploadRes.ErrorFlag == 0)
            {
                string FileExtension = Path.GetExtension(Request.Files[0].FileName); //获取扩展名
                fileName = uploadRes.Img1;
                Response.Write("上传成功!文件名:" + fileName + ",小写扩展名是:" + FileExtension.ToLower());
                //CartPicDetail cartpicDetail = new CartPicDetail();
                //cartpicDetail.CartPicID = cartPicID;
                //cartpicDetail.RecordID = recordID;
                //cartpicDetail.ProductID = productID;
                //cartpicDetail.GoodID = goodID;
                //cartpicDetail.PicPath = fileName;
                //cartpicDetail.Num = 1;

                //CartPicDB.AddCartPic(cartpicDetail, ref errorFlag, ref errorMsg);//插入数据库
            }
            else
            {
                Response.Write("上传购物车设计稿图片服务器出错:" + uploadRes.ErrorMsg);
                //XpShop.Logger.XpShopLogger.Logger("上传购物车设计稿图片服务器出错:" + uploadRes.ErrorMsg);
            }
        }
Пример #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                string         fileCName     = "";                                           //成功保存在图片服务器后的文件名
                HttpPostedFile files         = Request.Files[0];                             //获取文件
                string         FileExtension = Path.GetExtension(Request.Files[0].FileName); //获取扩展名

                if (FileExtension.ToLower() != "pdf")                                        //如果不是pdf文件
                {
                    string uploadResult;                                                     //上传结果

                    ImgUploadReq entity = new ImgUploadReq();
                    entity.Id    = 10;
                    entity.Type  = (int)ImgType.CartPic;
                    entity.File  = Context.Request.Files[0];
                    uploadResult = ImgClient.UploadImg(entity);
                    //获取上传后的返回信息
                    ImgUploadRes uploadRes = XpShopJSONHelper.Deserialize <XpShop.Client.Entity.ImgUploadRes>(uploadResult);

                    if (uploadRes.ErrorFlag == 0)
                    {
                        fileCName += uploadRes.Img1;
                    }
                }
                else
                {
                    Stream FileStream = files.InputStream;
                    ConvertPDF2Image(FileStream, "/Upload/PDF/", "testPDF", 1, 2, ImageFormat.Png, Definition.Ten);
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('错误!" + ex.Message + "');</script>");
            }
        }