background image

            int idx = uploadName.LastIndexOf(".");

            string suffix = uploadName.Substring(idx);//获得上传的图片的后缀名

            pictureName = DateTime.Now.Ticks.ToString() + suffix;

        }

        try

        {

            if (uploadName != "")

            {

                string path = Server.MapPath("~/images/");

                InputFile.PostedFile.SaveAs(path + pictureName);

            }

        }

        catch (Exception ex)

        {

            Response.Write(ex);

        }

    }

}

 

单文件上传

        这是最基本的文件上传,在 asp.net1.x 中没有这个 FileUpload 控件,只有 html 的