具体实现步骤:
1、修改
UCHOME目录如下文件
打开文件source/script_upload.js
找到:
01.var extensions = 'jpg,jpeg,gif,png';
复制代码修改为:
01.var extensions = 'jpg,jpeg,gif,png,rar,zip';
复制代码找到:
01.attachexts[id] = inArray(ext, ['gif', 'jpg', 'jpeg', 'png']) ? 2 : 1;
复制代码修改为:
01.attachexts[id] = inArray(ext, ['gif', 'jpg', 'jpeg', 'png', 'rar', 'zip']) ? 2 : 1;
复制代码2、打开文件source/function_cp.php
找到:
01.//允许
上传类型
02.$allowpictype = array('jpg','jpeg','gif','png');
复制代码修改为:
01.//允许上传类型
02.$allowpictype = array('jpg','jpeg','gif','png');
03.$allowothertype=array('rar','zip');
复制代码找到:
01.//判断后缀
02.$fileext = fileext($FILE['name']);
03.if(!in_array($fileext, $allowpictype)) {
04.return cplang('only_allows_upload_file_types');
05.}
复制代码修改为:
01.//判断后缀
02.$fileext = fileext($FILE['name']);
03.if(!(in_array($fileext, $allowpictype)||in_array($fileext, $allowothertype))) {
04.return cplang('only_allows_upload_file_types');
05.}
复制代码找到:
01.//检查是否图片
02.if(function_exists('getimagesize')) {
03. $tmp_imagesize = @getimagesize($new_name);
04. list($tmp_width, $tmp_height, $tmp_type) = (array)$tmp_imagesize;
05. $tmp_size = $tmp_width * $tmp_height;
06. if($tmp_size > 16777216 || $tmp_size < 4 || empty($tmp_type) || strpos($tmp_imagesize['mime'], 'flash') > 0) {
07. @unlink($new_name);
08. return cplang('only_allows_upload_file_types');
09. }
10.}
复制代码修改为:
01. //检查是否图片
02. if(function_exists('getimagesize')) {
03. $fileext = fileext($new_name);
04. if(in_array($fileext, $allowpictype)) {
05. $tmp_imagesize = @getimagesize($new_name);
06. list($tmp_width, $tmp_height, $tmp_type) = (array)$tmp_imagesize;
07. $tmp_size = $tmp_width * $tmp_height;
08. if($tmp_size > 16777216 || $tmp_size < 4 || empty($tmp_type) || strpos($tmp_imagesize['mime'], 'flash') > 0) {
09. @unlink($new_name);
10. return cplang('only_allows_upload_file_types');
11. }
12. }
13. }
复制代码3、打开source/function_blog.php
找到:
01.//未插入文章
02.foreach ($uploads as $value) {
03. $picurl = pic_get($value['filepath'], $value['thumb'], $value['remote'], 0);
04. $message .= "<div class=\"uchome-message-pic\"><img src=\"$picurl\"><p>$value[title]</p></div>";
05.}
复制代码修改为:
01.//未插入文章
02.foreach ($uploads as $value) {
03. $picurl = pic_get($value['filepath'], $value['thumb'], $value['remote'], 0);
04. $fileext = fileext($picurl);
05. if(in_array($fileext, array('jpg','jpeg','gif','png'))){
06. $message .= "<div class=\"uchome-message-pic\"><img src=\"$picurl\"><p>$value[title]</p></div>";
07. }
08. else{
09. $message .= "<p><div><a href=\"$picurl\">$value[filename]</a> ($value[size] byte)</p></div>";
10. }
11.}
复制代码4、打开source/cp_thread.php
找到:
01.//未插入文章
02.foreach ($uploads as $value) {
03. $picurl = pic_get($value['filepath'], $value['thumb'], $value['remote'], 0);
04. $message .= "<div class=\"uchome-message-pic\"><img src=\"$picurl\"><p>$value[title]</p></div>";
05.}
复制代码修改为:
01.//未插入文章
02.foreach ($uploads as $value) {
03. $picurl = pic_get($value['filepath'], $value['thumb'], $value['remote'], 0);
04. $fileext = fileext($picurl);
05. if(in_array($fileext, array('jpg','jpeg','gif','png'))){
06. $message .= "<div class=\"uchome-message-pic\"><img src=\"$picurl\"><p>$value[title]</p></div>";
07. }
08. else{
09. $message .= "<p><div><a href=\"$picurl\">$value[filename]</a> ($value[size] byte)</p></div>";
10. }
11.}
复制代码5、通过以上即可实现rar、zip类型文件上传。如果上传时不修改存储相册,则默认存储在默认相册里,因为不是图片文件,浏览时不能显示缩略图,影响美观。为解决这个问题,建议在相册里面建一个“
附件存储文件夹”,权限设为“仅自己可见”,这样上传时选定这个存储位置,就不会影响默认相册的图片预览效果,同时也不妨碍
日志中附件的下载链接。
6、文件打包,有需要的可直接下载,FTP工具以二进制方式上传到UCHOME目录覆盖原文件即可。
source.rar
2009-10-7 23:38 上传下载 (20.25 KB)
.