i have radEditor in web Project.
i click to image manager in radEditor and upload file by Upload Botton. example my file is "MyFile.jpg". my file save in server path whit name "MyFile.jpg".
i want to Change filename after upload in server and save it. i write FileUpload event:
public bool RadEditor1_FileUpload(object sender, string fileName)
{
string FileNameTemp = fileName.Substring(fileName.LastIndexOf("/") + 1);
string strExtension = System.IO.Path.GetExtension(FileNameTemp);
FileNameTemp = FileNameTemp +
"-" + Guid.NewGuid() + strExtension;
fileName = fileName.Substring(0, fileName.LastIndexOf(
"/") + 1) + FileNameTemp;
return true;
}
but file save yet whit name "MyFile.jpg".
secend question me :
how insert image by src:'http://Address Image' in run time RadEditor. in Insert Manager certainly should upload image.
i whold not use from HTML code.
please help me.
4 Answers, 1 is accepted
1) You can implement a FileSystemContentProvider and override the StoreFile method. See this forum for more information: Reduce Image File Size
using System;  
using System.Collections;  
using System.Configuration;  
using System.Data;  
using System.Web;  
using System.Web.Security;  
using System.Web.UI;  
using System.Web.UI.HtmlControls;  
using System.Web.UI.WebControls;  
using System.Web.UI.WebControls.WebParts;  
using Telerik.Web.UI;  
using System.Drawing;  
using System.IO;  
   
   
public partial class static_test_editor : System.Web.UI.Page  
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
        RadEditor1.ImageManager.ViewPaths = new string[]{"~/"};  
        RadEditor1.ImageManager.UploadPaths = new string[] { "~/" };  
        RadEditor1.ImageManager.DeletePaths = new string[] { "~/" };  
        RadEditor1.ImageManager.ContentProviderTypeName = typeof(myprovider).AssemblyQualifiedName;  
    }  
   
    public class myprovider : Telerik.Web.UI.Widgets.FileSystemContentProvider  
    {  
   
        public myprovider(HttpContext context, string[] searchPatterns, string[] viewPaths, string[] uploadPaths, string[] deletePaths, string selectedUrl, string selectedItemTag)  
            : base(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)  
        {  
        }  
   
        public bool ThumbnailCallback()  
        {  
            return false;  
        }  
   
        public override string StoreFile(UploadedFile file, string path, string name, params string[] arguments)  
        {  
   
            string result = base.StoreFile(file, path, name, arguments);  
   
            System.Drawing.Image.GetThumbnailImageAbort myCallback =  
                new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);  
   
            string fileName = Path.Combine(path, name);  
            //Create a copy of the image with a different size  
            using (System.Drawing.Image originalImage = Bitmap.FromStream(file.InputStream))  
            {  
                using (System.Drawing.Image thumbnail = originalImage.GetThumbnailImage(300, 300, myCallback, IntPtr.Zero))  
                {  
                    thumbnail.Save(Context.Server.MapPath(fileName));  
                }  
            }  
   
            return result;  
        }  
    }  
}   2) You can use the InsertImage manager to insert images with web paths.
Kind regards,
Rumen
the Telerik team
Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!
I am having a similar issue, I want to rename the uploaded files so non-latin characters are removed from its filename. I implemented my own FileSystemContentProvider, based in this post, and it works.
I am facing now 2 issues.
- When the image manager refreshes after the file upload, the newly uploaded (and renamed) file is not selected.
 - The check if a file with the same name exists doesn't work, since I make a rename of the file.
 
Do you have any advice on how to resolve these issues?
Here is my implementation of the FileSystemContentProvider 
* The Greek2GrEnglish function makes the character conversion of the file name. 
Imports SystemImports System.CollectionsImports System.ConfigurationImports System.DataImports System.WebImports System.Web.SecurityImports System.Web.UIImports System.Web.UI.HtmlControlsImports System.Web.UI.WebControlsImports System.Web.UI.WebControls.WebPartsImports Telerik.Web.UIImports System.IOPublic Class myProvider    Inherits Telerik.Web.UI.Widgets.FileSystemContentProvider    Public Sub New(context As HttpContext, searchPatterns As String(), viewPaths As String(), uploadPaths As String(), deletePaths As String(), selectedUrl As String, selectedItemTag As String)        MyBase.New(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)    End Sub    Public Overrides Function StoreFile(file As UploadedFile, path__1 As String, name As String, ParamArray arguments As String()) As String        Dim new_result As String = MyBase.StoreFile(file, path__1, Greek2GrEnglish(name), arguments)        Return new_result    End FunctionEnd Class
The provided code snippet looks OK and I am not quite sure why do you experience the reported behavior.
Could you please verify that the result returned by StoreFile() method is the correct path to the file? Also, could you please open a formal support ticket and provide a sample fully runnable project reproducing the problem?
All the best,
Dobromir
the Telerik team
I am really sorry for not replying in a timely manner, but I guess I missed the notification email for your reply.
The code I posted is correct, there was a bug outside this code.
Thank you
