background image

                                //{
                                //    File.Delete(savePath);
                                //}
                                //postedFile.SaveAs(savePath);

                            }
                            else
                            {
                                //检查是否在服务器上已经存在用户上传的同名文件
                                if (File.Exists(savePath))
                                {
                                    File.Delete(savePath);
                                }
                                postedFile.SaveAs(savePath);
                            }
                        }
                        else
                        {
                            //检查是否在服务器上已经存在用户上传的同名文件
                            if (File.Exists(savePath))
                            {
                                File.Delete(savePath);
                            }
                            postedFile.SaveAs(savePath);
                        }
                    }
                }
                return fileName;
            }
            catch (Exception ex)
            {
                
            }
            return null;
        }

        /// <summary>  
                ///  

     

无 损 压 缩 图 片

//public static bool CompressImage(string sFile, string dFile, int 

dHeight, int dWidth, int flag)
        /// </summary>  
        /// <param name="postedFile">原图片</param>  
        /// <param name="dFile">压缩后保存位置</param>  
        /// <param name="dHeight">高度</param>  
        /// <param name="dWidth">宽度</param>