<form action="filetrees_Security_Target_Number_uploaded.php" method="post" enctype="multipart/form-data">
<span>选择图片:</span>
<input type="file" name="file" id="files" >
<input type="submit" value="上传图片1" οnclick="btnfyx()" style="width: 90px;background-color: rgb(116, 218, 252);color: white;border-color: rgb(116, 218, 252);border-width:2px;border-radius:5px;font-size: 15px;">
</form>
<?php
// var_dump($_FILES);
if($_FILES['file']['error'] !=0){
// echo "上传图片有误!";
echo "<script>alert('请选择图片!');history.go(-1);</script>";//history.go(-1);返回上一页不刷新
exit;
}
if($_FILES['file']['type'] =='image/gif' || $_FILES['file']['type'] =='image/jpeg' || $_FILES['file']['type'] =='image/png' || $_FILES['file']['type'] =='image/jpg')
{
$result =move_uploaded_file($_FILES["file"]["tmp_name"],"assets/UploadFile/" . $_FILES["file"]["name"]);//文件存储位置
if($result){
echo "<script>alert('上传图片成功!');history.go(-1);</script>";
// echo "上传图片成功";
}
// echo "\r\n文件存储在: " . "assets/UploadFile/" . $_FILES["file"]["name"];
}else{
echo "<script>alert('上传有误,请选择图片格式为gif/jpeg/png/jpg上传!');history.go(-1);</script>";//history.go(-1);返回上一页不刷新
// echo "请选择图片格式为gif/jpeg/png/jpg上传";
}
?>