I recently upgraded to the latest version of the Ajax Control Toolkit (July 2013), and am working with the new HtmlEditorExtender with the image upload button added. For some reason when I upload anything, it does not complely upload the file. An example would be images, they are only being partially uploaded, causing them to be corrupt and not display correctly. I have tested this will very small images (around 300k) up to large images that are roughly around 4mb.
Here is my code:
Default.aspx
<%@ Page Title="Home Page" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %><asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"></asp:Content><asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"><asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager><asp:TextBox ID="TextBox1" runat="server" Height="290px" Width="911px"></asp:TextBox><asp:HtmlEditorExtender ID="TextBox1_HtmlEditorExtender" runat="server" Enabled="True" DisplaySourceTab="True" TargetControlID="TextBox1"><Toolbar><asp:InsertImage /></Toolbar></asp:HtmlEditorExtender></asp:Content>
Default.aspx.vb
Imports AjaxControlToolkit Partial Class _Default Inherits System.Web.UI.Page Protected Sub TextBox1_HtmlEditorExtender_ImageUploadComplete(sender As Object, e As AjaxControlToolkit.AjaxFileUploadEventArgs) Handles TextBox1_HtmlEditorExtender.ImageUploadComplete 'Remove any special characters that may create an upload error: Dim cleanedUpFilename As String = CleanUpFilename(e.FileName) Dim imageUpload = DirectCast(sender, AjaxFileUpload) 'Save the file to the drive imageUpload.SaveAs("c:\inetpub\ameriwealth-content\" & cleanedUpFilename) ' Generate file path url Dim urlToImage As String = "http://localhost:48500/" & cleanedUpFilename 'Update client with saved image path e.PostedUrl = urlToImage End Sub Private Function CleanUpFilename(inputFileName As String) As String Dim workingFilename As String = inputFileName workingFilename = HttpUtility.UrlDecode(workingFilename) workingFilename = Replace(workingFilename, " ", "-") Return workingFilename End Function End Class
Steps to recreate the error:
1. Click the image button in the html editor
2. Select any image file
3. Click upload
4. The progress bar never seems to get to 100%, usually says complete at around 90%-97% give or take
I've been VB coding for a ridiculously long time, but I cannot seem to get this thing right. Probably something simple that I am missing, but the main issue is for some reason, the control is deciding to stop uploading before it is complete.
The code written was adapter from the C# code listed on this blog:
http://stephenwalther.com/archive/2012/05/01/ajax-control-toolkit-may-2012-release
If anyone can point me in the right direction, I would greatly appreciate it.