upload.php 917 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. $filename = $_FILES["file"]["name"];
  3. $temp = explode(".", $filename);
  4. $csign = $_GET['sign'];
  5. $time = $_GET['t'];
  6. $sign = md5( $filename."_lvjunxi_".$time );
  7. $extension = end($temp); // 获取文件后缀名
  8. $data = array('code'=>201, 'filename'=>$filename);
  9. if( $sign != $csign ){
  10. $data["msg"] = "error sign";
  11. echo json_encode( $data );
  12. return;
  13. }
  14. if ( $_FILES["file"]["size"] < 409600 && $extension == "pdf"){
  15. if ($_FILES["file"]["error"] > 0){
  16. $data["msg"] = "error file";
  17. echo json_encode( $data );
  18. }else{
  19. try{
  20. $res=move_uploaded_file($_FILES["file"]["tmp_name"], "pdf/".$filename );
  21. $data["code"] = "200";
  22. echo json_encode( $data );
  23. } catch (Exception $e) {
  24. echo $e->getMessage();
  25. }
  26. }
  27. }else{
  28. $data["msg"] = "error size";
  29. echo json_encode( $data );
  30. }
  31. ?>