change filename of file uploaded with image selector

Last post 06-29-2009, 8:35 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  06-27-2009, 3:22 PM 53572

    change filename of file uploaded with image selector

    Is it possible to rename the filename of an image that is uploaded with the image selector? In general can we get access to this file upload object and modify the uploaded file?
     
    Thanks
     
    Lorne
    Filed under:
  •  06-29-2009, 8:35 AM 53585 in reply to 53572

    Re: change filename of file uploaded with image selector

    Hi kommander47,
     
    1. Open file InsertImage.aspx (CuteSoft_Client\CuteEditor\Dialogs\InsertImage.aspx)
     
    2. Find section <CE:Uploader id="InputFile" runat="server"></CE:Uploader>
     
    3. Add section <CE:Uploader id="anotheruploader" runat=server OnFileUploaded="anotheruploader_FileUploaded"></CE:Uploader> under the section above, like
     
    <CE:Uploader id="InputFile" runat="server"></CE:Uploader>
    <CE:Uploader id="anotheruploader" runat=server OnFileUploaded="anotheruploader_FileUploaded"></CE:Uploader>
     
    4. Find section <script runat="server"></script>
     
    5. Add the code below into the section above
     
    protected override void OnPreRender(EventArgs args)
    {
        base.OnPreRender(args);
        anotheruploader.Visible = InputFile.Visible;
        InputFile.InsertButton.Style["display"] = "none";
        anotheruploader.InsertText = InputFile.InsertText;
        anotheruploader.CancelText = InputFile.CancelText;
        anotheruploader.MultipleFilesUpload = InputFile.MultipleFilesUpload;
        anotheruploader.ValidateOption.MaxSizeKB = InputFile.ValidateOption.MaxSizeKB;
        anotheruploader.ValidateOption.AllowedFileExtensions = InputFile.ValidateOption.AllowedFileExtensions;
    }
    void anotheruploader_FileUploaded(object sender, UploaderEventArgs args)
    {
        using (System.IO.Stream stream = args.OpenStream())
        {
                //custom the file name here
            InputFile.Upload(args.FileSize, DateTime.Now.ToString("yyyy-MM-dd") + " " + args.FileName, stream);
          
        }
    }
     
    6. Now, you can test the InsertImage function
     
    Regards,
     
    Ken
View as RSS news feed in XML