<form method="post" action="index.php" enctype="multipart/form-data">
<input type="hidden" name="action" value="upload">
<input type="file" name="u_file">
<input type="submit" name="アップロート">
</form>
<?php
if ($_POST[action]=="upload") {
$file_path="./uploads\\";
$picture_name=$_FILES[u_file][name];
$picture_name=strstr($picture_name, ".");
if ($picture_name!=".jpg") {
echo "
<script type='text/javascript'>
alert('not jpg');
windows.location.href='index.php';
</script>
";
}elseif ($_FILES[u_file][tmp_name]) {
move_uploaded_file($_FILES[u_file][tmp_name], $file_path.$_FILES[u_file][name]);//图片上传
echo "upload success";
}else{
echo "upload fail";
}
}
?>
PHP检索字符串(strstr)文件上传查找指定(.jpg)文件
最新推荐文章于 2021-12-25 16:12:12 发布