21,886
社区成员
发帖
与我相关
我的任务
分享
iconv('UTF-8','gbk',$_FILES['userfile']['name']);
iconv('UTF-8','gb2312',$_FILES['userfile']['name']);
iconv('gbk','UTF-8',$_FILES['userfile']['name']);
iconv('gb2312','UTF-8',$_FILES['userfile']['name']);
<html>
<head>
<title>Administration - upload new files</title>
</head>
<body>
<h1>Upload new news files</h1>
<form action="upload.php" method="post" enctype="multipart/form-data">
<div>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000"/>
<label for="userfile">Upload a file:</label>
<input type="file" name="userfile" id="userfile"/>
<input type="submit" value="Send File"/>
</div>
</form>
</body>
</html>
<html>
<head>
<title>Uploading...</title>
</head>
<body>
<h1>Uploading file...</h1>
<?php
$filename=iconv('UTF-8','gbk',$_FILES['userfile']['name']);
$upfile='../uploads/'.$filename;
if(is_uploaded_file($_FILES['userfile']['tmp_name'])){
if(!move_uploaded_file($_FILES['userfile']['tmp_name'],$upfile)){
echo "Problem:Could not move file to destination directory.";
exit;
}
}else{
echo "Problem:Possible file upload attack.Filename:".$filename;
exit;
}
echo "File uploaded successfully.<br/><br/>";
?>
</body>
</html>