In "add image upload function to freetextbox", we implemented the image upload function. However, in actual use, I found some minor problems, such as automatically adding domain names, this makes the migration of the website inconvenient, for example. After some research, we have finally successfully solved these small problems, made a record in the form of this article, and shared it with you.
The original idea was to return " ", and the Editor automatically adds the domain name to us :(.
After reading the Js of freetextbox, we found the executecommand function, which makes it easy for us to create an IMG object. First, we need to extend a method called insertpuresrc:
FTB_FreeTextBox.prototype.InsertPureSrc = function(imgSrc) {if (imgSrc != '') {this.ExecuteCommand('insertimage',null,imgSrc);}}
Here, imgsrc is the image address, and then we modify a piece of returned content that is uploaded successfully:
//string s = "opener.InsertText('" + s + @"');window.close();</script>");Response.End();
Directly return the image address, and finally modify the inserttext function called for the insertpuresrc we added above:
function InsertText(textToInsert) {FTB_API['<%=FreeTextBox1.ClientID %>'].InsertPureSrc(textToInsert);}
This completes. upload an image and try it. Now we have inserted the returned content. The domain name is not automatically added, as shown in.
- Download the sample code in this article