| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 503 人关注过本帖
标题:图片上传程序问题
只看楼主 加入收藏
xbw0114
Rank: 1
等 级:新手上路
帖 子:141
专家分:0
注 册:2007-8-8
收藏
 问题点数:0 回复次数:0 
图片上传程序问题
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string name = FileUpload1.FileName;
        string size = FileUpload1.PostedFile.ContentLength.ToString();
        string type = FileUpload1.PostedFile.ContentType;
        string type2 = name.Substring(name.LastIndexOf(".") + 1);
        string ipath= Server.MapPath("upimg") + "\\" + name;
        string fpath = Server.MapPath("upfile") + "\\" + name;
        string wpath = "upimg\\" + name;
        if (type2 == "jpg" || type2 == "gif" || type2 == "bmp" || type2 == "png")
        {
            FileUpload1.SaveAs(ipath);
            Image1.ImageUrl = wpath;
            Label1.Text = "你传如的文件名是:" + name + "<br>文件夹大小为:" + size + "字节<br>文件类型是:" + type + "<br>后缀名是:" + type2;
        }
        else
        {
            Image1.Visible = false;
            FileUpload1.SaveAs(fpath);
            Label1.Text = "你传如的文件名是:" + name + "<br>文件夹大小为:" + size + "字节<br>文件类型是:" + type + "<br>后缀名是:" + type2;
        }
            }

    }
为什么我运行以后发生错误   未能找到路径,能帮忙解决下吗?
2007-12-23 14:39
快速回复:图片上传程序问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024247 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved