Sep 29, 2013, 2:39 PM
[CLOSED] after upload the picture , then add picture to the htmleditor, but not work
<ext:FileUploadField runat="server" LabelWidth="65" Margin="4" FieldLabel="上传图片" AnchorHorizontal="100%" ButtonText="浏览" ID="fuf">
<DirectEvents>
<Change OnEvent="ClickedUpload"></Change>
</DirectEvents>
</ext:FileUploadField>
<ext:HtmlEditor runat="server" ID="he_cont" AnchorVertical="-90" AnchorHorizontal="100%">
</ext:HtmlEditor>
protected void ClickedUpload(object o, DirectEventArgs e)
{
if (this.fuf.HasFile)
{
var fname = this.fuf.PostedFile.FileName;
var flength = this.fuf.PostedFile.ContentLength;
Random ran = new Random();
string sNewName = DateTime.Now.ToString(@"yyyy-MM-dd-HH-mm-ss") + ran.Next(100, 999)
+ Path.GetExtension(this.fuf.PostedFile.FileName);
string strPath = HttpContext.Current.Server.MapPath("/Uploads/" + System.DateTime.Now.Year.ToString() + "/" + sNewName);
string path_moth = HttpContext.Current.Server.MapPath("/Uploads/" + System.DateTime.Now.Year.ToString());
if (!Directory.Exists(path_moth))
{
Directory.CreateDirectory(path_moth);
}
this.fuf.PostedFile.SaveAs(strPath);
he_cont.Text += "<img src='+"+strPath+"'/>"; // here i add image tag to the htmleditor,
he_cont.Render();//then rerender or render it , but the picture dose not show.
X.Msg.Alert("消息", "上传成功").Show();
}
else
{
X.Msg.Alert("消息", "上传失败").Show();
}
}
Last edited by Daniil; Oct 08, 2013 at 6:43 AM.
Reason: [CLOSED]