I tried (and am trying) really hard to resolve an issue but im a little stuck as to how to proceed.
Ive asked a lot of these forums recently so i apolagise for asking yet another question (I will get the hang of .NET if it kills me )
As the title says, i am trying to incorporate an HTML Editor and an Image upload facility.
I first tried the editor which comes with the AJAX Tool Kit. Easy to implement, no problems there. But i couldnt find an image uploader which said it worked with it except one (which i forget the name of) which i couldnt get to work.
So i have implemented the CKEditor which also works fine. Not wanting to pay for the CKFinder i implemented the KCFinder (A free alternative). I followed thei nstructions, integration guide and online help and cannot get it to work.
When i go to browse server it tries to download the browse.php instead of reading it.
When i go to upload, select my file and press ok the tiny bar goes grey.
I copied and pasted the error into word so i could view it and after googling the error i found that i needed to set the cookie as local host (as im just testing it locally)
However now i get another error (Shown below the post)
Is anyone here familiar with KCFinder? Or another Image uploader which integrates with CKEditor? Or even a completely different setup?
I dont mind what i use i just want something which works.
I apreciate your help.
Dariune
<div class="content">P.s. the error ...</div> <div class="content"></div> <div href="memberlist.php?mode=viewprofile&u=322">Server Error in '/' Application.
The HTTP verb POST used to access path '/kcfinder/upload.php' is not allowed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The HTTP verb POST used to access path '/kcfinder/upload.php' is not allowed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): The HTTP verb POST used to access path '/kcfinder/upload.php' is not allowed.]
System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) +2874378
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8682818
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:2.0.50727.4961; ASP.NET Version:2.0.50727.4955</div>
I see you have tried CKEditor... You can raelly easily implement your own file upload service with CKEditor and dont have to use CKFinder, or any 3rd party tools...
Here is a guide it is built for MVC2 but can easily be adapted for your use.
For the asp.net component you can simple use a generic handler which is similar to a MVC controller.
Your handler will take in a file upload and will save the file into a file store and return the result.
First you will need to create a handler.. for simple sakes i created it in my ckeditor folder called Upload.ashx so the path is ~/ckeditor/upload.ashx. Next we copy the following code to handle when you upload a file... its commented and pretty simple..
We simply extract all the details from the ckeditor post including the file, the editor functions, the name of the editor. Save the file to the local machine. THen on returing you simply need to call back a html script to execute a function in the ckeditor
to display a message and prepare the image. Here is the handler code. Note you will have to change the save path to the actual place you wish to save to
public void ProcessRequest(HttpContext context)
{
string CKEditorFuncNum = context.Request["CKEditorFuncNum"];
string CKEditor = context.Request["CKEditor"];
string langCode = context.Request["langCode"];
string url; // url to return
string message; // message to display (optional)
try
{
//no files upload just send an alert script
if (context.Request.Files.Count == 0)
{
context.Response.Write("<html><body><script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"\", \"No file upload. Upload cancelled\");</script></body></html>");
context.Response.End();
}
//get our file from the context.
HttpPostedFile upload = context.Request.Files[0];
// here logic to upload image
// and get file path of the image
// path of the image
string path = upload.FileName;
//create your URL path
url = context.Request.Url.GetLeftPart(UriPartial.Authority) + "/" + path;
//create our absolute store path
var savePath = context.Server.MapPath(string.Format("~/{0}", path));
//save the upload
upload.SaveAs(savePath);
// passing message success/failure
message = "Image was saved correctly";
// since it is an ajax request it requires this string
string output = @"<html><body><script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"" + url + "\", \"" + message + "\");</script></body></html>";
//write out our output
context.Response.Write(output);
}
catch {
context.Response.Write("<html><body><script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"\", \"An Error occurred while uploading your file. Upload cancelled\");</script></body></html>");
}
}
The next step is to just set the upload handler in your ckeditor instance creation. This is one simple line of code
WNow we are complete, the file will be uploaded and saved to the server. When complete you will get an alert saying it was successful and have your image.
To upload the image, simply click on the image button, select the upload tab and your going.
Actually i think i will try the Obout one first (Though the documentation is so abundant it appears confusing.
If i can help it i would rather not have PHP on my project because if anything goes wrong i wont be able to fix it where as with .NET i stand a chance of fixing it.
There seems to be no way to install it. The auto install cant locate my Visual Studios and when i follow the guide it tells me to add the editor.dll to the toolbox. Problem is, there isnt an editor dll.
Anyone able ot help? I in genuine awe of how hard it is to get an image manager into .NET.
Ive tried ckEditor (Which works but has no image upload/manager facility)
KC Editor (Which wont work because i am not setup for PHP)
Ive created my own upload (Which works but has no file manager) - attached to CKEditor
Ive tried pgrFileManager whichalso wont work due to being PHP
Ive tried one called FileManager which just gets stuck on the loading screen
And ive tried the AJAX Control kit which doesnt have an upload facility.
Im currently trying to get Obout to install.
Thanks again guys. It seems to be a tricky one and i apreciate all help :)
dariune
Member
116 Points
106 Posts
HTML Editor and Image uploader
Aug 11, 2011 09:19 PM|LINK
Hi all
I tried (and am trying) really hard to resolve an issue but im a little stuck as to how to proceed.
Ive asked a lot of these forums recently so i apolagise for asking yet another question (I will get the hang of .NET if it kills me )
As the title says, i am trying to incorporate an HTML Editor and an Image upload facility.
I first tried the editor which comes with the AJAX Tool Kit. Easy to implement, no problems there. But i couldnt find an image uploader which said it worked with it except one (which i forget the name of) which i couldnt get to work.
So i have implemented the CKEditor which also works fine. Not wanting to pay for the CKFinder i implemented the KCFinder (A free alternative). I followed thei nstructions, integration guide and online help and cannot get it to work.
When i go to browse server it tries to download the browse.php instead of reading it.
When i go to upload, select my file and press ok the tiny bar goes grey.
I copied and pasted the error into word so i could view it and after googling the error i found that i needed to set the cookie as local host (as im just testing it locally)
However now i get another error (Shown below the post)
Is anyone here familiar with KCFinder? Or another Image uploader which integrates with CKEditor? Or even a completely different setup?
I dont mind what i use i just want something which works.
I apreciate your help.
Dariune
<div class="content">P.s. the error ...</div> <div class="content"></div> <div href="memberlist.php?mode=viewprofile&u=322">Server Error in '/' Application.The HTTP verb POST used to access path '/kcfinder/upload.php' is not allowed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The HTTP verb POST used to access path '/kcfinder/upload.php' is not allowed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): The HTTP verb POST used to access path '/kcfinder/upload.php' is not allowed.]
System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) +2874378
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8682818
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:2.0.50727.4961; ASP.NET Version:2.0.50727.4955</div>
nvanhaaster@...
Star
9209 Points
1484 Posts
Re: HTML Editor and Image uploader
Aug 12, 2011 02:17 AM|LINK
I see you have tried CKEditor... You can raelly easily implement your own file upload service with CKEditor and dont have to use CKFinder, or any 3rd party tools...
Here is a guide it is built for MVC2 but can easily be adapted for your use.
File And Image Upload with ASP.NET MVC2 with CKEditor
For the asp.net component you can simple use a generic handler which is similar to a MVC controller.
Your handler will take in a file upload and will save the file into a file store and return the result.
First you will need to create a handler.. for simple sakes i created it in my ckeditor folder called Upload.ashx so the path is ~/ckeditor/upload.ashx. Next we copy the following code to handle when you upload a file... its commented and pretty simple.. We simply extract all the details from the ckeditor post including the file, the editor functions, the name of the editor. Save the file to the local machine. THen on returing you simply need to call back a html script to execute a function in the ckeditor to display a message and prepare the image. Here is the handler code. Note you will have to change the save path to the actual place you wish to save to
public void ProcessRequest(HttpContext context) { string CKEditorFuncNum = context.Request["CKEditorFuncNum"]; string CKEditor = context.Request["CKEditor"]; string langCode = context.Request["langCode"]; string url; // url to return string message; // message to display (optional) try { //no files upload just send an alert script if (context.Request.Files.Count == 0) { context.Response.Write("<html><body><script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"\", \"No file upload. Upload cancelled\");</script></body></html>"); context.Response.End(); } //get our file from the context. HttpPostedFile upload = context.Request.Files[0]; // here logic to upload image // and get file path of the image // path of the image string path = upload.FileName; //create your URL path url = context.Request.Url.GetLeftPart(UriPartial.Authority) + "/" + path; //create our absolute store path var savePath = context.Server.MapPath(string.Format("~/{0}", path)); //save the upload upload.SaveAs(savePath); // passing message success/failure message = "Image was saved correctly"; // since it is an ajax request it requires this string string output = @"<html><body><script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"" + url + "\", \"" + message + "\");</script></body></html>"; //write out our output context.Response.Write(output); } catch { context.Response.Write("<html><body><script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"\", \"An Error occurred while uploading your file. Upload cancelled\");</script></body></html>"); } }The next step is to just set the upload handler in your ckeditor instance creation. This is one simple line of code
<script type="text/javascript"> CKEDITOR.replace('Body', { filebrowserImageUploadUrl: '/ckeditor/Upload.ashx' }); </script>WNow we are complete, the file will be uploaded and saved to the server. When complete you will get an alert saying it was successful and have your image.
To upload the image, simply click on the image button, select the upload tab and your going.
My .Net Blog
My Links are shrunk by t-ny.co
dariune
Member
116 Points
106 Posts
Re: HTML Editor and Image uploader
Aug 13, 2011 09:27 AM|LINK
Thats fantastic!!!
I did get an error and was sitting there scratching my head when i realised my Firewall was on. Add an exception and job done. Thanks for that.
I dont suppose its as easy to add an Image browser is it?
Thanks for your help man.
dariune
Member
116 Points
106 Posts
Re: HTML Editor and Image uploader
Aug 13, 2011 03:18 PM|LINK
Hmmmm just tried pgrfilemanager and i am getting the same problem.
I go to browse server and it tries to download the pgrfilemanager.php instead of use it.
So it must be soething im doing wrong :(
I will keep trying.
HaMiD Fadaei
Member
2 Points
1 Post
Re: HTML Editor and Image uploader
Aug 13, 2011 11:13 PM|LINK
Very Good.
Thanks a lot.
ــحمید فداییــ
* - طراح وبـــ
* - گرافیستـــ
* - برنامه نویســ
سایت شخصی:http://www.hfadaei.ir
uploader
Jungalist
Participant
1839 Points
409 Posts
Re: HTML Editor and Image uploader
Aug 14, 2011 01:06 AM|LINK
Your server isn't setup to serve PHP pages so it thinks the request is for a download.
sreejukg
All-Star
27535 Points
4105 Posts
Re: HTML Editor and Image uploader
Aug 14, 2011 02:16 AM|LINK
try this
http://www.obout.com/Obout.Ajax.UI/HTMLEditor/
My Blog
dariune
Member
116 Points
106 Posts
Re: HTML Editor and Image uploader
Aug 14, 2011 09:29 AM|LINK
How do i set it up to handle php?
Actually i think i will try the Obout one first (Though the documentation is so abundant it appears confusing.
If i can help it i would rather not have PHP on my project because if anything goes wrong i wont be able to fix it where as with .NET i stand a chance of fixing it.
I will try Obout and get back to you
dariune
Member
116 Points
106 Posts
Re: HTML Editor and Image uploader
Aug 14, 2011 10:04 AM|LINK
Have you used Obout before?
There seems to be no way to install it. The auto install cant locate my Visual Studios and when i follow the guide it tells me to add the editor.dll to the toolbox. Problem is, there isnt an editor dll.
Anyone able ot help? I in genuine awe of how hard it is to get an image manager into .NET.
Ive tried ckEditor (Which works but has no image upload/manager facility)
KC Editor (Which wont work because i am not setup for PHP)
Ive created my own upload (Which works but has no file manager) - attached to CKEditor
Ive tried pgrFileManager whichalso wont work due to being PHP
Ive tried one called FileManager which just gets stuck on the loading screen
And ive tried the AJAX Control kit which doesnt have an upload facility.
Im currently trying to get Obout to install.
Thanks again guys. It seems to be a tricky one and i apreciate all help :)
Savageflash
Member
28 Points
11 Posts
Re: HTML Editor and Image uploader
Aug 25, 2011 02:07 PM|LINK
I personally use Telerik RAD editor. It his an HTML editor, as well as an Image manager. It does it all.
You can read about it here.
RAD Tools for ASP.Net