Delete application name in URL after uploading with Fckeditor

Fckeditor is an open source online html editor. In my project I use it in the article-add page. The usage is very easy, all you need to do is put the "fckeditor" folder under Web-Root directory and write some lines as below:
 <script>
           var editor = new FCKeditor('content');
           editor.BasePath='/myproject/fckeditor/';
           editor.ToolbarSet='UserToolbar';
           editor.Create();
</script>
 
Of course there are other attributes with "editor", you can set them according to you quirements. What I want to mention is the upload function. When we use the upload function, take "image upload" for example, after uploading the image, generally, which we choose from our local PC, the frame change to "Attribute" window automatically, and the URL for the image we just uploaded like this: /myproject/userfiles/image/myimage.jpg. It is OK when I test the function on my own computer, but something wrong happens when I do the same thing on the Internet. Because on my computer I use the IP to connect the Web-application but on the Internet I use the domain name. For example, the domain name is http://my.myforge.org and it is binding to an IP 192.168.0.1:8080/myproject. After uploading the image, I get the URL as follows: /myproject/myproject/userfiles/image/myimage.jpg. It is easy to find that the "myproject" is duplicated and the image can't be linked exactly to the server. The domain binding to the IP can't be changed, so I try to alter the URL the "uploading function" returned.
 
After  study on the source code, I solve the problem at last and it is only a matter of one centence.Take "image upload" for instance, first open fck_image.js under fckeditor/editor/dialog/fck_image. You could find a function OnUploadCompleted(), near the bottom line of the function you could find SetUrl(fileUrl);, then I change it to: fileUrl = fileUrl.substring(10,fileUrl.length); SetUrl( fileUrl ) ;.The result of this chang is the first /myproject will be deleted before it is returned to the "Attribute" window. The number 10 is mutative according to you application name.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值