1

我需要上传图片。我编码如下:

string filename = "";
            string FilePath = "";
            filename = Path.GetFileName(FileImage.FileName);
            FilePath = Server.MapPath("./JQueryImages");
            string destPath = Path.Combine(FilePath, filename);
            FileImage.PostedFile.SaveAs(destPath);
            ViewState["ImagePath"] = destPath.ToString();
            ImgUploaded.ImageUrl = destPath;
            LblUploadMsg.Text = "Image uploaded successfully";
            LblUploadMsg.ForeColor = Color.Green;

图像进入一个文件夹JQueryImages,但我有一个图像控件ImgUploaded在加载时不显示图像。当我检查我的解决方案文件夹图像时没有加载。我需要to include each image上传后。我不想包含每个图像。什么可以解决这个问题。感谢您的帮助。

4

1 回答 1

0
 string filename = "";
            string FilePath = "";
            filename = Path.GetFileName(FileUpload1.FileName);
            FilePath = Server.MapPath("./JQueryImages");
            string destPath = Path.Combine(FilePath, filename);
            FileUpload1.PostedFile.SaveAs(destPath);
            ViewState["ImagePath"] = destPath.ToString();
            Image1.ImageUrl = "~/JQueryImages/" + filename;
            Label1.Text = "Image uploaded successfully";
            Label1.ForeColor = Color.Green;

这是我使用的最终代码。现在可以了。

于 2013-02-25T06:58:31.677 回答