用php写的文件上传代码,可是上传在指定目录里的文件的文件名是乱码~~
<?php
$uptypes=array("application/msword","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.ms-publisher","application/vnd.ms-powerpoint","application/vnd.ms-excel");//上传文件类型列表
$destination_folder="file/"; //上传文件路径
?>
<form enctype="multipart/form-data" method="post" name="upform">
<table>
<tr>
<td height="30">上传文档:</td>
</tr>
<tr>
<td height="30"><input name="upfile" type="file" class="file_submit"></td>
</tr>
<tr>
<td>允许上传的文件类型: doc, xls, ppt, docx, xlsx, pptx</td>
</tr>
<tr>
<td><input type="submit" value="上 传" class="picturesubmit_botton"></td>
</tr>
</table>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
?>
<div class="picturemessage">
<?php
if(!is_uploaded_file($_FILES['upfile'][tmp_name]))
//是否存在文件
{
echo "文件大小请不要超过4M!";
}else{
$file = $_FILES['upfile'];
if(!in_array($file['type'], $uptypes))
//检查文件类型
{
echo "文件类型不符!".$file['type'];
}else{
if(!file_exists($destination_folder))
{
mkdir($destination_folder);
}
$filename=$file['tmp_name'];
$image_size = getimagesize($filename);
$thefilename= $file['name'];
$destination = $destination_folder.$thefilename;
if (file_exists($destination) && $overwrite != true)
{
echo "<font color=red>同名文件已经存在了</font>";
}else{
if(!move_uploaded_file ($filename, $destination))
{
echo "<font color=red>移动文件出错!</font>";
}else{
date_default_timezone_set('Asia/Shanghai');
$date=date("Y-m-d H:i:s");
$author=$teamname[$team-1];
$input="INSERT INTO `article_menu` ( `num` , `title` , `author` , `article` , `date` , `picture` , `team` , `key` , `clicknum` )
VALUES (
NULL , '$thefilename', '$author', '', '$date', '0', '$team', '5', '0'
)";
$response=mysql_query($input);
$change=mysql_query("UPDATE `order` SET `num` = num+1 WHERe `order`.`team` =$team LIMIT 1");
mysql_close($select);
echo "<font color=red>已经成功上传</font><br>文件名:<font color=blue><a href=\"".$destination_folder.$fname."\">".$fname."</a></font><br>";
echo "大小:".$file['size']." bytes";
}}}}
?>
</div>
<?php
}
?>