搜索
查看: 4346|回复: 0

文件上传绕过求解答

[复制链接]

1

主题

11

回帖

47

积分

vip用户

积分
47
发表于 2019-11-15 16:19:19 | 显示全部楼层 |阅读模式

<html>
<meta http-equiv="Content-Type" content="textfile:///C:\Users\mask\AppData\Local\Temp\@IR3P(8S$C$Z$TY~5I{QEPC.gifml; charset=UTF-8" />
<title>服务端路径突破上传</title>
<form method="post" name="upform" action="" enctype="multipart/form-data">
        <input type="file" name="file">
        <input type="hidden" name="path" value="upfile">
        <input type="submit" value="upload" name="up">
</form>

<file:///C:\Users\mask\AppData\Local\Temp\@IR3P(8S$C$Z$TY~5I{QEPC.gifml>

<?php


if(isset($_POST['up'])|| !empty($_POST['UP'])){

if($_FILES['file']['error'] > 0){
   echo '!problem:';
   switch($_FILES['file']['error'])
   {
     case 1: echo '文件大小超过服务器限制';
             break;
     case 2: echo '文件太大!';
             break;
     case 3: echo '文件只加载了一部分!';
             break;
     case 4: echo '文件加载失败!';
             break;
   }
   
   exit;
}
}



if($_FILES['file']['size'] > 1000000){
   echo '文件过大!';
   exit;
}
if($_FILES['file']['type']!='image/jpeg' && $_FILES['file']['type']!='image/gif'){
   echo '文件不是JPG或者GIF图片!';
   exit;
}
$today = date("YmdHis");
$filetype = $_FILES['file']['type'];
if($filetype == 'image/jpeg'){
  $type = '.jpg';
}
if($filetype == 'image/gif'){
  $type = '.gif';
}

function checkPath($_patch){
                if (!is_dir($_patch) || !is_writeable($_patch)) {
                        if (!mkdir($_patch)) {
                        exit('ERRIR:创建目录失败');
                        }
                }
}
checkPath($_POST['path']);
$upfile =  $_POST['path']."/". $today . $type;
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
   if(!move_uploaded_file($_FILES['file']['tmp_name'], $upfile))
   {
     echo '移动文件失败!';
     exit;
    }
}
else
{
   echo 'problem!';
   exit;
}
echo '<h1>success!</h1><br>';
echo '文件大小:' . $_FILES['file']['size'] . '字节' . '<Br>';
echo '文件路径:' . $upfile;
echo '<hr with="100%" />' . '<p>';
$dirr = 'upfile/';
$dir = opendir($dirr);
echo $dirr . '--Listing:<ul>';
while($file = readdir($dir)){
  echo "<li>$file<[img]file:///C:\Users\mask\AppData\Local\Temp\)A[Y)I~](ZC9Z[3Y)IDK7LK.gif[/img]>";
}
echo '</ul>';
closedir($dir);
?>



回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表