menu
more_vert
简单文件上传

作者:dayu

/* 检查文件类型 */
if ($_FILES[‘upfile_flash‘][‘type‘] != "application/x-shockwave-flash")
{
$link[] = array(‘text‘ => $_LANG[‘go_back‘], ‘href‘ => ‘javascript:history.back(-1)‘);
sys_msg($_LANG[‘upfile_flash_type‘], 0, $link);
}
/* 生成文件名 */
$urlstr = date(‘Ymd‘);
for ($i = 0; $i < 6; $i++)
{
$urlstr .= chr(mt_rand(97, 122));
}

$source_file = $_FILES[‘upfile_flash‘][‘tmp_name‘];
$target = ROOT_PATH . DATA_DIR . ‘/afficheimg/‘;
$file_name = $urlstr .‘.swf‘;

if (!move_upload_file($source_file, $target.$file_name))
{
$link[] = array(‘text‘ => $_LANG[‘go_back‘], ‘href‘ => ‘javascript:history.back(-1)‘);
sys_msg($_LANG[‘upfile_error‘], 0, $link);
}
else
{
$ad_code = "ad_code = ‘$file_name‘, ";
}

简单文件上传

原文地址:http://www.cnblogs.com/csjoz/p/7244067.html