This is a migrated thread and some comments may be shown as answers.
Change filename after upload in server in RadEditor
4 Answers 72 Views
This is a migrated thread and some comments may be shown as answers.
hossein
Top achievements
Rank 1
hossein asked on 20 Jul 2011, 05:57 AM

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

Sort by
0
Rumen
Telerik team
answered on 21 Jul 2011, 04:36 PM
Hello Hossein,

1) You can implement a FileSystemContentProvider and override the StoreFile method. See this forum for more information: http://www.telerik.com/community/forums/aspnet-ajax/editor/reduce-image-file-size.aspx

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!

0
neowebgr
Top achievements
Rank 2
answered on 11 May 2012, 12:29 PM
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

0
Dobromir
Telerik team
answered on 16 May 2012, 08:11 AM
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,
Dobromir
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.
0
neowebgr
Top achievements
Rank 2
answered on 05 Dec 2012, 12:28 PM
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
Asked by
hossein
Top achievements
Rank 1
Answers by
Rumen
Telerik team
neowebgr
Top achievements
Rank 2
Dobromir
Telerik team
Share this question
or