close
function 圖片上傳前() { tinymce.activeEditor.execCommand('mceInsertContent', false, '#changeimagehere#'); } <asp:Button ID="按鈕_上傳圖片" runat="server" Text="上傳" OnClientClick="圖片上傳前()" class="btn btn-success" OnClick="按鈕_上傳圖片_Click" CausesValidation="true" ValidationGroup="上傳圖片" UseSubmitBehavior="false" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="※請選擇上傳圖片" ValidationGroup="上傳圖片" ControlToValidate="FileUpload2" Display="Dynamic" ></asp:RequiredFieldValidator><asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="FileUpload2" ValidationGroup="上傳圖片" ErrorMessage="※只能上傳副檔名為 .jpg 或.gif 或.png 的檔案" ValidationExpression="^.+\.(((g|G)(i|I)(f|F))|((j|J)(p|P)(e|E)?(g|G))|((p|P)(n|N)(g|G)))$" Display="Dynamic"></asp:RegularExpressionValidator> protected void 按鈕_上傳圖片_Click(object sender, EventArgs e) { string savePath = @"uploads/"; ImageProcess.上傳圖片(FileUpload2, ref savePath, ref errCode); System.Drawing.Image objImage = System.Drawing.Image.FromFile(Server.MapPath(savePath)); int width = objImage.Width; int height = objImage.Height; string 換圖片 = "<img src=\"" + savePath + "\" width=\"" + width + "\" height=\"" + height + "\">"; commentBox.InnerText = commentBox.InnerText.Replace("#changeimagehere#", 換圖片); 檔案管理(); }
全站熱搜
留言列表