FCKEditor arquivo Upload - não funciona no servidor de produção - “Arquivo inválido”
Pergunta
Eu tenho FCKEditor (2.6.4) trabalhando em minha máquina de desenvolvimento com o conector aspx para upload de arquivos (é um site asp.net), mas eu não consigo descobrir como obtê-lo trabalhando na máquina de produção. Arrgh. Passamos 4 horas sobre isso e chegado a lugar nenhum.
Ao que tudo indica, parece ser um problema de permissões, mas:
- Eu duplo e triplo-verificado que IUSR e ASPNET e Serviço de Rede (e até "Todos", por agora) tem permissão para arquivos de gravação na pasta "userfiles" que é o destino para o envio.
- Eu tenho seguido a letra da lei na criação de fckconfig.js
Sintomas:
- Editor de funciona bem. O usuário pode inserir texto, etc.
- O usuário pode clicar no botão inserir imagem, que traz o seletor de imagem. Pode inserir uma imagem que já existe no servidor apenas multa.
- Pode ir para o diálogo de carregamento de arquivo e criar com sucesso uma nova pasta no servidor através da UI fckeditor.
- Mas sempre que o usuário tenta fazer o upload de uma pequena e válido .png, .jpg, .gif, qualquer imagem (que funciona bem no meu localhost aqui), Firefox dá-me uma mensagem "Invalid File". (Eu tentei com vários arquivos de imagem válidos de diferentes tamanhos e formatos. Nenhum trabalho. A imagem não fique carregado para o servidor.)
código relevante de fckconfig.js:
`
var _FileBrowserLanguage = 'aspx';
var _QuickUploadLanguage = 'aspx';
// não se preocupam com as duas linhas seguintes. Ele só calcula o conector correto // extensão de uso para o navegador de arquivo padrão (Perl usa "cgi"). var _FileBrowserExtension = _FileBrowserLanguage == 'perl'? 'Cgi': _FileBrowserLanguage; var _QuickUploadExtension = _QuickUploadLanguage == 'perl'? 'Cgi': _QuickUploadLanguage; `
código de fckeditor \ editor \ filemanager \ conectores \ aspx \ config.ascx:
`UserFilesPath = "~ / userfiles /";
// The connector tries to resolve the above UserFilesPath automatically.
// Use the following setting it you prefer to explicitely specify the
// absolute path. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' URL must point to the same directory.
string ap = HttpContext.Current.Server.MapPath("~/userfiles/");
UserFilesAbsolutePath = ap;
//UserFilesAbsolutePath = "C:\\inetpub\\wwwroot\\hot-bigoven\\userfiles\\";
//UserFilesAbsolutePath = "C:\\inetpub\\wwwroot\\bigovenwebapp\\bigovenwebapp\\userfiles\\";
// Due to security issues with Apache modules, it is recommended to leave the
// following setting enabled.
//ForceSingleExtension = true;
// Allowed Resource Types
AllowedTypes = new string[] { "File", "Image", "Flash", "Media" };
// For security, HTML is allowed in the first Kb of data for files having the
// following extensions only.
HtmlExtensions = new string[] { "html", "htm", "xml", "xsd", "txt", "js" };
TypeConfig[ "File" ].AllowedExtensions = new string[] { "7z", "aiff", "asf", "avi", "bmp", "csv", "doc", "fla", "flv", "gif", "gz", "gzip", "jpeg", "jpg", "mid", "mov", "mp3", "mp4", "mpc", "mpeg", "mpg", "ods", "odt", "pdf", "png", "ppt", "pxd", "qt", "ram", "rar", "rm", "rmi", "rmvb", "rtf", "sdc", "sitd", "swf", "sxc", "sxw", "tar", "tgz", "tif", "tiff", "txt", "vsd", "wav", "wma", "wmv", "xls", "xml", "zip" };
TypeConfig[ "File" ].DeniedExtensions = new string[] { };
TypeConfig[ "File" ].FilesPath = "%UserFilesPath%file/";
TypeConfig[ "File" ].FilesAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%file/" );
TypeConfig[ "File" ].QuickUploadPath = "%UserFilesPath%";
TypeConfig[ "File" ].QuickUploadAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%" );
TypeConfig[ "Image" ].AllowedExtensions = new string[] { "bmp", "gif", "jpeg", "jpg", "png" };
TypeConfig[ "Image" ].DeniedExtensions = new string[] { };
TypeConfig[ "Image" ].FilesPath = "%UserFilesPath%image/";
TypeConfig[ "Image" ].FilesAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%image/" );
TypeConfig[ "Image" ].QuickUploadPath = "%UserFilesPath%";
TypeConfig[ "Image" ].QuickUploadAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%" );
TypeConfig[ "Flash" ].AllowedExtensions = new string[] { "swf", "flv" };
TypeConfig[ "Flash" ].DeniedExtensions = new string[] { };
TypeConfig[ "Flash" ].FilesPath = "%UserFilesPath%flash/";
TypeConfig[ "Flash" ].FilesAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%flash/" );
TypeConfig[ "Flash" ].QuickUploadPath = "%UserFilesPath%";
TypeConfig[ "Flash" ].QuickUploadAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%" );
TypeConfig[ "Media" ].AllowedExtensions = new string[] { "aiff", "asf", "avi", "bmp", "fla", "flv", "gif", "jpeg", "jpg", "mid", "mov", "mp3", "mp4", "mpc", "mpeg", "mpg", "png", "qt", "ram", "rm", "rmi", "rmvb", "swf", "tif", "tiff", "wav", "wma", "wmv" };
TypeConfig[ "Media" ].DeniedExtensions = new string[] { };
TypeConfig[ "Media" ].FilesPath = "%UserFilesPath%media/";
TypeConfig[ "Media" ].FilesAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%media/" );
TypeConfig[ "Media" ].QuickUploadPath = "%UserFilesPath%";
TypeConfig[ "Media" ].QuickUploadAbsolutePath = ( UserFilesAbsolutePath == "" ? "" : "%UserFilesAbsolutePath%" );
`
Solução
Eu mudei para usando o conector "ASP", e ele funciona perfeitamente. Por alguma razão, o conector aspx não funcionou no meu local de produção (mas trabalhou na máquina dev), mas o conector ASP funciona bem.
Não é bem uma "resposta", mas uma solução alternativa eficaz.