关于PHP上传文件名称,如果修改,可以使上传的文件保存原有的文件名! 本帖最后由 ligenwin 于 2012-06-06 01:38:23 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 上传组件引用文件<?phpdefined('IN_PHPCMS') or exit('Access Denied');require_once 'attachment.class.php';session_start();$attachment = new attachment($mod);$_SESSION['downfiles'] = 1;if($dosubmit){ if($catid) { $C = cache_read('category_'.$catid.'.php'); $upload_allowext = $C['upload_allowext'] ? $C['upload_allowext'] : UPLOAD_ALLOWEXT; $upload_maxsize = $C['upload_maxsize'] ? $C['upload_maxsize'] : UPLOAD_MAXSIZE; } else { $upload_allowext = UPLOAD_ALLOWEXT; $upload_maxsize = UPLOAD_MAXSIZE; } $aids = $attachment->upload('uploadfile', $upload_allowext, $upload_maxsize, 1); if(!$aids) { msg($attachment->error(), '', 6000); exit; } $atts = $attachment->uploadedfiles; $filesize = $attachment->uploadedfiles[0]['filesize']; $filesize = $attachment->size($filesize); foreach($atts AS $k=>$v) { $name = $file_description[$k+1]; if($name=='') { $name = basename($v['filename'],'.'.$v['fileext']); } echo '<script>var s = parent.document.getElementById("downurls").value == "" ? "" : "#";var t = parent.document.getElementById("downurls_aid").value == "" ? "" : ",";parent.document.getElementById("downurls").value += s+"'.$name.'|'.$filesize.'|'.UPLOAD_URL.$v['filepath'].'|适用机型:";parent.document.getElementById("downurls_aid").value += t+"'.$aids[$k].'";parent.document.getElementById("filesize").value="'.$v['filesize'].'";</script>'; } echo '<script>parent.document.getElementById("filesize").value="'.$filesize.'";</script>'; msg('上传成功', '', 3000);}else{ include admin_tpl('downfiles');}function msg($msg, $forward = '', $timeout = 2000){ if(!$forward) { global $forward; } echo '<table width="100%" cellpadding="0" cellspacing="0" height="100%" bgcolor="#F1F3F5">'; echo '<tr><td style="font-size:12px;color:blue;">'; echo '<a href="'.$forward.'">'.$msg.' Click To Back</a>'; echo '</td></tr></table>'; echo '<script>setTimeout("window.location=\''.$forward.'\'", '.$timeout.');</script>'; exit;}?> php 如何退出foreach 循环 PHP的页面链接问题 php/关于rar文件的处理 为什么用foreach输出的结果是倒序的?请给高手帮忙,谢谢。 字符串分割问题(保留分割符) 什么是PHP的CGI模式 The requested operation has failed FastCGI Error PHP中通过返回值进行页面跳转的问题! php数据查询分页 做过 DEDE CMS 的帮忙看下!急!谢谢!! 怎么把二维数组放到mysql中.
<?php
defined('IN_PHPCMS') or exit('Access Denied');require_once 'attachment.class.php';
session_start();
$attachment = new attachment($mod);
$_SESSION['downfiles'] = 1;
if($dosubmit)
{
if($catid)
{
$C = cache_read('category_'.$catid.'.php');
$upload_allowext = $C['upload_allowext'] ? $C['upload_allowext'] : UPLOAD_ALLOWEXT;
$upload_maxsize = $C['upload_maxsize'] ? $C['upload_maxsize'] : UPLOAD_MAXSIZE;
}
else
{
$upload_allowext = UPLOAD_ALLOWEXT;
$upload_maxsize = UPLOAD_MAXSIZE;
}
$aids = $attachment->upload('uploadfile', $upload_allowext, $upload_maxsize, 1);
if(!$aids)
{
msg($attachment->error(), '', 6000);
exit;
}
$atts = $attachment->uploadedfiles;
$filesize = $attachment->uploadedfiles[0]['filesize'];
$filesize = $attachment->size($filesize);
foreach($atts AS $k=>$v)
{
$name = $file_description[$k+1];
if($name=='')
{
$name = basename($v['filename'],'.'.$v['fileext']);
}
echo '<script>var s = parent.document.getElementById("downurls").value == "" ? "" : "#";var t = parent.document.getElementById("downurls_aid").value == "" ? "" : ",";parent.document.getElementById("downurls").value += s+"'.$name.'|'.$filesize.'|'.UPLOAD_URL.$v['filepath'].'|适用机型:";parent.document.getElementById("downurls_aid").value += t+"'.$aids[$k].'";parent.document.getElementById("filesize").value="'.$v['filesize'].'";</script>';
}
echo '<script>parent.document.getElementById("filesize").value="'.$filesize.'";</script>';
msg('上传成功', '', 3000);
}
else
{
include admin_tpl('downfiles');
}function msg($msg, $forward = '', $timeout = 2000)
{
if(!$forward)
{
global $forward;
}
echo '<table width="100%" cellpadding="0" cellspacing="0" height="100%" bgcolor="#F1F3F5">';
echo '<tr><td style="font-size:12px;color:blue;">';
echo '<a href="'.$forward.'">'.$msg.' Click To Back</a>';
echo '</td></tr></table>';
echo '<script>setTimeout("window.location=\''.$forward.'\'", '.$timeout.');</script>';
exit;
}
?>