aspx代码
<x:ContentPanel ID="pnl_title" runat="server" BodyPadding="5px" ShowBorder="true" ShowHeader="true" Title="ContentPanel" EnableAjax="false"> <div id="div_display" runat="server"> </div></x:ContentPanel>
<x:FileUpload ID="filePhoto" runat="server" Label="文件上传" >
</x:FileUpload>
<x:Button ID="btnUpload" runat="server" Text="确认上传">
</x:Button>
aspx.cs
protected void btnUpload_Click(object sender,EventArgs e) { //自动创建文件夹 AutoCreatDir(Server.MapPath(Image_upload_path)); //文件上传 if (filePhoto.HasFile) { string fileName = filePhoto.ShortFileName; fileName = fileName.Replace(":", "_").Replace(" ", "_").Replace("\\", "_").Replace("/", "_"); fileName = DateTime.Now.Ticks.ToString() + "_" + fileName; //Alert.Show(string.Format("{0}{1}", Image_upload_path, fileName)); //return; filePhoto.SaveAs(Server.MapPath(string.Format("{0}/{1}", Image_upload_path, fileName))); //DisplayImages();
int index = int.Parse(hid_list.Value);//要修改的索引 string[] temp = hid_div_img_select.Value.Split(Join_char);
List<string> list = new List<string>(); for (int i = 0; i < Count; i++) { if (i == index) { list.Add(fileName); } else { list.Add(temp[i]); } } hid_div_img_select.Value = string.Join(Join_char.ToString(), list.ToArray()); Alert.Show(hid_div_img_select.Value); //Alert.Show("请选择要上传的图片"); //return; } //重新绑定泛型 pnl_Title_Append(); //关闭window win_Image_Select.Popup = false; }
|