FCKEditor 文件上传 - 无法在生产服务器上工作 - “无效文件”
我的开发机器上有 FCKEditor (2.6.4),带有用于文件上传的 aspx 连接器(它是一个 asp.net 网站),但我不知道如何让它在生产机器上运行。 啊啊。 花了4个小时在这上面,却一无所获。
从表面上看,这似乎是一个权限问题,但是:
- 我已经仔细检查了 IUSR 和 ASPNET 和网络服务(甚至现在的“每个人”)是否有权在“userfiles”文件夹上写入文件是上传的目标。
- 我在设置 fckconfig.js 时遵循了法律条文
症状:
- 编辑器工作正常。 用户可以输入文本等。
- 用户可以单击插入图像按钮,这会弹出图像选择器。 可以插入服务器上已经存在的图像就好了。
- 可以进入文件上传对话框并通过 fckeditor UI 在服务器上成功创建新文件夹。
- 但每当用户尝试上传小而有效的 .png、.jpg、.gif 或任何图像(在我的本地主机上运行正常)时,Firefox 都会给我一条“无效文件”消息。 (我尝试过许多不同大小和格式的有效图像文件。没有任何效果。图像不会上传到服务器。)
来自 fckconfig.js 的相关代码:
` var _FileBrowserLanguage = 'aspx' ;
var _QuickUploadLanguage = 'aspx' ;
// 不用关心下面两行。 它只是计算正确的连接器 // 用于默认文件浏览器的扩展名(Perl 使用“cgi”)。 var _FileBrowserExtension = _FileBrowserLanguage == 'perl' ? 'cgi' : _FileBrowserLanguage ; var _QuickUploadExtension = _QuickUploadLanguage == 'perl' ? 'cgi' : _QuickUploadLanguage ; `
fckeditor\editor\filemanager\connectors\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%" );
`
I have FCKEditor (2.6.4) working on my development machine with the aspx connector for file upload (it's an asp.net website), but I cannot figure out how to get it working on the production machine. Arrgh. Have spent 4 hours on this and gotten nowhere.
By all appearances it seems to be a permissions issue, but:
- I've double and triple-checked that IUSR and ASPNET and Network Service (and even "Everyone", for now) has permission to write files on the "userfiles" folder that is the target for the upload.
- I've followed the letter of the law in setting up fckconfig.js
Symptoms:
- Editor works fine. User can enter text, etc.
- User can click the insert image button, which brings up the image chooser. Can insert an image that already exists on the server just fine.
- Can go into the file-upload dialog and successfully create a new folder on the server via the fckeditor UI.
- But whenever the user tries to upload a small and valid .png, .jpg, .gif, any image (which works OK on my localhost here), Firefox gives me an "Invalid File" message. (I've tried with numerous valid image files of varying sizes and formats. None work. The image does not get uploaded to the server.)
relevant code from fckconfig.js:
`
var _FileBrowserLanguage = 'aspx' ;
var _QuickUploadLanguage = 'aspx' ;
// Don't care about the following two lines. It just calculates the correct connector
// extension to use for the default File Browser (Perl uses "cgi").
var _FileBrowserExtension = _FileBrowserLanguage == 'perl' ? 'cgi' : _FileBrowserLanguage ;
var _QuickUploadExtension = _QuickUploadLanguage == 'perl' ? 'cgi' : _QuickUploadLanguage ;
`
code from fckeditor\editor\filemanager\connectors\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%" );
`
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已改用“ASP”连接器,它工作得很好。 由于某种原因,.aspx 连接器无法在我的生产站点上工作(但可以在开发计算机上工作),但 ASP 连接器工作正常。
不完全是一个“答案”,而是一个有效的解决方法。
I have switched to using the "ASP" connector, and it works perfectly. For some reason, the .aspx connector didn't work on my production site (but worked on the dev machine), but the ASP connector works fine.
Not quite an "answer", but an effective workaround.