遨游死神文章列表

html5上传

<!DOCTYPE html>

<html>

<head>

    <title>Html5 Ajax 上传文件</title>

    <script type="text/javascript">



        function UpladFile() {
            console.log(11)


            var fileObj = document.getElementById("file").files[0]; // 获取文件对象

            var FileController = "http://localhost:8080/Javar-fast/oss/files/upload";                    // 接收上传文件的后台地址 

           

            // FormData 对象

            var form = new FormData();

            form.append("author", "chenji");                        // 可以增加表单数据

            form.append("file", fileObj);                           // 文件对象



            // XMLHttpRequest 对象

            var xhr = new XMLHttpRequest();

            xhr.open("post", FileController, true);

            xhr.onload = function () {

                alert("上传完成!");

            };

            xhr.send(form);



        }

</script>

</head>

<body>
    
<input type="file" id="file" name="myfile" />

<input type="button" onclick="UpladFile()" value="上传" />
<br>
<br>
<br>
<br>
<br>
<br>
<br>
https://www.172u.cn/ 一起遨游网提供
</body>

</html>

MYSQL 先判断后插入数据防止超出

 insert into enterprisecontrol
                (enterprise_id,control_id,time,status)
                SELECT #{enterprise_id},#{control_id},#{time},#{status}
    from DUAL  
where not exists(select enterprisecontrol.enterpriseControl_id from enterprisecontrol where enterprise_id = #{enterprise_id} and control_id = #{control_id} );

可能不管用,不过写了以后明显可以控制

phpBOM头(字符&#65279;)出现的原因以及解决方法

<?php 
if (isset($_GET['dir'])){ //设置文件目录
$basedir=$_GET['dir']; 
}else{ 
$basedir = '.'; 
} 
$auto = 1; 
checkdir($basedir); 
function checkdir($basedir){ 
if ($dh = opendir($basedir)) { 
  while (($file = readdir($dh)) !== false) { 
   if ($file != '.' && $file != '..'){ 
    if (!is_dir($basedir."/".$file)) { 
     echo "filename: $basedir/$file ".checkBOM("$basedir/$file")." <br>"; 
    }else{ 
     $dirname = $basedir."/".$file; 
     checkdir($dirname); 
    } 
   } 
  } 
closedir($dh); 
} 
} 
function checkBOM ($filename) { 
global $auto; 
$contents = file_get_contents($filename); 
$charset[1] = substr($contents, 0, 1); 
$charset[2] = substr($contents, 1, 1); 
$charset[3] = substr($contents, 2, 1); 
if (ord($charset[1]) == 239 && ord($charset[2]) == 187 && ord($charset[3]) == 191) { 
  if ($auto == 1) { 
   $rest = substr($contents, 3); 
   rewrite ($filename, $rest); 
   return ("<font color=red>BOM found, automatically removed.</font>"); 
  } else { 
   return ("<font color=red>BOM found.</font>"); 
  } 
} 
else return ("BOM Not Found."); 
} 
function rewrite ($filename, $data) { 
$filenum = fopen($filename, "w"); 
flock($filenum, LOCK_EX); 
fwrite($filenum, $data); 
fclose($filenum); 
} 
?>

另存为php 即可批量修改