ckfinder 怎么给上传的文件改名 .

解决方案 »

  1.   

    ckfinder\_source\Connector\CommandHandlers\FileUploadCommandHandler.cs
    里面去看代码,上传修改是在这里的
      

  2.   

    while ( true )
    {
    sFilePath = System.IO.Path.Combine( sServerDir, sFileName ); if ( System.IO.File.Exists( sFilePath ) )
    {
    iCounter++;
    sFileName =
    sFileNameNoExt +
    "(" + iCounter + ")" +
    System.IO.Path.GetExtension( oFile.FileName ); iErrorNumber = Errors.UploadedFileRenamed;
    }
    else
    {
    oFile.SaveAs( sFilePath ); if ( Config.Current.SecureImageUploads && ImageTools.IsImageExtension( sExtension ) && !ImageTools.ValidateImage( sFilePath ) )
    {
    System.IO.File.Delete( sFilePath );
    ConnectorException.Throw( Errors.UploadedCorrupt );
    } Settings.Images imagesSettings = Config.Current.Images; if ( imagesSettings.MaxHeight > 0 && imagesSettings.MaxWidth > 0 )
    {
    ImageTools.ResizeImage( sFilePath, sFilePath, imagesSettings.MaxWidth, imagesSettings.MaxHeight, true, imagesSettings.Quality ); if ( Config.Current.CheckSizeAfterScaling && this.CurrentFolder.ResourceTypeInfo.MaxSize > 0 )
    {
    long fileSize = new System.IO.FileInfo( sFilePath ).Length;
    if ( fileSize > this.CurrentFolder.ResourceTypeInfo.MaxSize )
    {
    System.IO.File.Delete( sFilePath );
    ConnectorException.Throw( Errors.UploadedTooBig );
    }
    }
    } break;
    }
    }就这段代码if ( System.IO.File.Exists( sFilePath ) )
    {
    iCounter++;
    sFileName =
    sFileNameNoExt +
    "(" + iCounter + ")" +
    System.IO.Path.GetExtension( oFile.FileName ); iErrorNumber = Errors.UploadedFileRenamed;
    }
      

  3.   

    修改 ckfinder\_source\Connector\CommandHandlers\FileUploadCommandHandler.cs 文件string sExtension = System.IO.Path.GetExtension( oFile.FileName );
    sExtension = sExtension.TrimStart( '.' );
    sFileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "." + sExtension;