是在asp.net C# 中
哪位好心人帮帮忙啊

解决方案 »

  1.   

    UpLoadImg.aspx
         <form id="AcaIssue" method="post" encType="multipart/form-data" runat="server">
    ====================================================================
    UpLoadImg.aspx.cs
         //====================================================
         //=====================上传文件=======================
         //====================================================//得到本地文件的完整路径,即file框中的值
    string localpath=this.Pic_Link.PostedFile.FileName.ToString();

    //得到本地文件名和扩展名
    FileName=System.IO.Path.GetFileName(localpath);//生成随机数rd
    string rd=System.DateTime.Now.Ticks.ToString();

    //为文件名加前缀,并加上随机数
    FileName="AcaTeam"+rd+FileName;//获取得目的物理路径
    AimPath=this.Server.MapPath("Photo\\");//判断指定文件夹是否存在,不存在就建立
    if(System.IO.Directory.Exists(AimPath)==false)
    {
        //文件夹不存在,则建立一个文件夹
        System.IO.Directory.CreateDirectory(AimPath);
    }

    //生成完整路径(包括文件名)
    AimPath+=FileName;//文件另存为
    this.Pic_Link.PostedFile.SaveAs(AimPath);//测试文件是否已成功上传,如果上传的文件大小为0字节,则,视其为上传失败//
    System.IO.FileInfo fi=new System.IO.FileInfo(AimPath);
    long i=fi.Length;if(i==0)
    {
        //先把要删除的文件的属性设正常(非只读......)
        System.IO.File.SetAttributes(AimPath,System.IO.FileAttributes.Normal);    //将产生的0字节文件删除
        System.IO.File.Delete(AimPath);
        war="但,你的本地文件信息不正确,上传失败。";
    }//====================================================
      

  2.   

    别忘了,aspx中
    <INPUT id="Pic_Link" type="file" name="File1" runat="server">