Re: change filename of file uploaded with image selector

  •  06-29-2009, 8:35 AM

    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 Complete Thread