Change filename after upload in server in RadEditor

5 posts, 0 answers
  1. hossein
    hossein avatar
    1 posts
    Member since:
    Jul 2011

    Posted 20 Jul 2011 Link to this post

    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.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.

  2. Rumen
    Rumen avatar
    12788 posts

    Posted 21 Jul 2011 Link to this post

    Hello Hossein,

    1) You can implement a FileSystemContentProvider and override the StoreFile method. See this forum for more information:

    2) You can use the InsertImage manager to insert images with web paths.

    Kind regards,
    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!

  3. DevCraft R3 2016 release webinar banner
  4. neowebgr
    neowebgr avatar
    5 posts
    Member since:
    Nov 2005

    Posted 11 May 2012 Link to this post

    Hello there,

    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.
    1. When the image manager refreshes after the file upload, the newly uploaded (and renamed) file is not selected.
    2. 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 System
    Imports System.Collections
    Imports System.Configuration
    Imports System.Data
    Imports System.Web
    Imports System.Web.Security
    Imports System.Web.UI
    Imports System.Web.UI.HtmlControls
    Imports System.Web.UI.WebControls
    Imports System.Web.UI.WebControls.WebParts
    Imports Telerik.Web.UI
    Imports System.IO
    Public 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 Function
    End Class

  5. Dobromir
    Dobromir avatar
    1633 posts

    Posted 16 May 2012 Link to this post

    Hi Stathis,

    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,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. neowebgr
    neowebgr avatar
    5 posts
    Member since:
    Nov 2005

    Posted 05 Dec 2012 Link to this post

    Hello Dobromir,

    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
Back to Top
DevCraft R3 2016 release webinar banner