NoteOnMe博客平台搭建
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 line
2.4 KiB

4 年之前
  1. <?php
  2. $a=array("a"=>1,"b"=>2);
  3. if(!empty($_FILES['file']['name'])){
  4. //判断是否有文件
  5. $fileinfo = $_FILES['file']; //将文件信息赋给变量$fileinfo
  6. echo "上传成功";
  7. if($fileinfo['size']<1000000 && $fileinfo['size']>0){ //判断文件大小
  8. move_uploaded_file($_FILES["file"]['tmp_name'],"image/".$fileinfo['name']);
  9. echo "上传成功";
  10. $filepath="image/".$fileinfo['name'];
  11. echo "
  12. <script src='test8.js' type='text/javascript' ></script>
  13. <script>
  14. append_img('$filepath');
  15. </script>
  16. ";
  17. $a=2;
  18. }else{
  19. echo '文件太大或未知';
  20. }
  21. }
  22. ?>
  23. <html>
  24. <head>
  25. <style>
  26. body {
  27. background-color: #efefef;
  28. }
  29. .profile-pic {
  30. max-width: 200px;
  31. max-height: 200px;
  32. display: block;
  33. }
  34. .circle {
  35. border-radius: 1000px !important;
  36. overflow: hidden;
  37. width: 128px;
  38. height: 128px;
  39. border: 8px solid rgba(255, 255, 255, 0.7);
  40. position: absolute;
  41. top: 72px;
  42. }
  43. img {
  44. max-width: 100%;
  45. height: auto;
  46. }
  47. .p-image {
  48. position: absolute;
  49. top: 167px;
  50. right: 30px;
  51. color: #666666;
  52. transition: all .3s cubic-bezier(.175, .885, .32, 1.275);
  53. }
  54. .p-image:hover {
  55. transition: all .3s cubic-bezier(.175, .885, .32, 1.275);
  56. }
  57. .upload-button {
  58. font-size: 1.2em;
  59. }
  60. .upload-button:hover {
  61. transition: all .3s cubic-bezier(.175, .885, .32, 1.275);
  62. color: #999;
  63. }
  64. </style>
  65. </head>
  66. </html>
  67. <script type="text/javascript" src="jquery.min.js"></script>
  68. <script>
  69. $(document).ready(function() {
  70. var readURL = function(input) {
  71. if (input.files && input.files[0]) {
  72. var reader = new FileReader();
  73. reader.onload = function (e) {
  74. $('.profile-pic').attr('src', e.target.result);
  75. }
  76. reader.readAsDataURL(input.files[0]);
  77. }
  78. }
  79. $(".file-upload").on('change', function(){
  80. readURL(this);
  81. });
  82. $(".upload-button").on('click', function() {
  83. $(".file-upload").click();
  84. });
  85. });
  86. </script>
  87. <div class="row">
  88. <div class="small-12 medium-2 large-2 columns">
  89. <div class="circle">
  90. <!-- User Profile Image -->
  91. <img class="profile-pic" >
  92. <!-- Default Image -->
  93. <!-- <i class="fa fa-user fa-5x"></i> -->
  94. </div>
  95. <div class="p-image">
  96. <i class="fa fa-camera upload-button"></i>
  97. <input class="file-upload" type="file" accept="image/*"/>
  98. </div>
  99. </div>
  100. </div>