1 回答
TA贡献1799条经验 获得超6个赞
这将起作用,您应该指定正确的路径
<?php
if($_SERVER["REQUEST_METHOD"] == "POST"){
$imageinfo = getimagesize($_FILES['img']['tmp_name']);
if($imageinfo['mime'] != 'image/gif' && $imageinfo['mime'] != 'image/jpeg') {
echo "<center><br>Sorry, we only accept GIF and JPEG images</b><br>param name: img<br>u can upload
with CSRF";
exit;
}
else{
$uploaddir = '../path-to-move/';
$uploadfile = $uploaddir . basename($_FILES['img']['name']);
if (move_uploaded_file($_FILES['img']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "File uploading failed.\n";
}
}
}?>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method="post" enctype="multipart/form-data">
<input type="file" size="20" name="img" />
<input type="submit" name="upload" value="Upload" />
- 1 回答
- 0 关注
- 80 浏览
添加回答
举报