Wapegocode Bnduongdz nè cho rôi đừng niếm đá nhé

14 bài đăng
30.05.2018 / 21:31
minhmon
Bài đăng: 25
Member
HTML5
  1. <?php
  2. // Ấn định dung lượng file ảnh upload
  3. define ("MAX_SIZE","100");
  4.  
  5. // hàm này đọc phần mở rộng của file. Nó được dùng để kiểm tra nếu
  6. // file này có phải là file hình hay không .
  7. function getExtension($str) {
  8. $i = strrpos($str,".");
  9. if (!$i) { return ""; }
  10. $l = strlen($str) - $i;
  11. $ext = substr($str,$i+1,$l);
  12. return $ext;
  13. }
  14.  
  15. //This variable is used as a flag. The value is initialized with 0 (meaning no
  16. // error found)
  17. //and it will be changed to 1 if an errro occures.
  18. //If the error occures the file will not be uploaded.
  19. $errors=0;
  20. //checks if the form has been submitted
  21. if(isset($_POST['Submit']))
  22. {
  23. // lấy tên file upload
  24. $image=$_FILES['image']['name'];
  25. // Nếu nó không rỗng
  26. if ($image)
  27. {
  28. // Lấy tên gốc của file
  29. $filename = stripslashes($_FILES['image']['name']);
  30. //Lấy phần mở rộng của file
  31. $extension = getExtension($filename);
  32. $extension = strtolower($extension);
  33. // Nếu nó không phải là file hình thì sẽ thông báo lỗi
  34. if (($extension != "jpg") && ($extension != "jpeg") && ($extension !=
  35. "png") && ($extension != "gif"))
  36. {
  37. // xuất lỗi ra màn hình
  38. echo '<h1>Đây không phải là file hình!</h1>';
  39. $errors=1;
  40. }
  41. else
  42. {
  43. //Lấy dung lượng của file upload
  44. $size=filesize($_FILES['image']['tmp_name']);
  45. if ($size > MAX_SIZE*1024)
  46. {
  47. echo '<h1>Vượt quá dung lượng cho phép!</h1>';
  48. $errors=1;
  49. }
  50.  
  51. // đặt tên mới cho file hình up lên
  52. $image_name=time().'.'.$extension;
  53. // gán thêm cho file này đường dẫn
  54. $newname="images/".$image_name;
  55. // kiểm tra xem file hình này đã upload lên trước đó chưa
  56. $copied = copy($_FILES['image']['tmp_name'], $newname);
  57. if (!$copied)
  58. {
  59. echo '<h1> File hình này đã tồn tại </h1>';
  60. $errors=1;
  61. }}}}
  62.  
  63. if(isset($_POST['Submit']) && !$errors)
  64. {
  65. echo "<h1>File hình đã được Upload thành công </h1>";
  66. }
  67.  
  68. ?>
  69.  
  70. <!-- nhớ đặt enctype to "multipart/frm-data"
  71. và sử dụng input type "file" -->
  72. <form name="newad" method="post" enctype="multipart/form-data"
  73. action="">
  74. <table>
  75. <tr><td><input type="file" name="image"></td></tr>
  76. <tr><td><input name="Submit" type="submit" value="Upload image">
  77. </td></tr>
  78. </table>
  79. </form>

code php nhé up hinh tốt nhất

30.05.2018 / 22:37
Koollzboy
Bài đăng: 178
Member
Đam Mê Chứ Đell Phải Nghiện
minhmon đã viết
HTML5
  1. <?php
  2. // Ấn định dung lượng file ảnh upload
  3. define ("MAX_SIZE","100");
  4.  
  5. // hàm này đọc phần mở rộng của file. Nó được dùng để kiểm tra nếu
  6. // file này có phải là file hình hay không .
  7. function getExtension($str) {
  8. $i = strrpos($str,".");
  9. if (!$i) { return ""; }
  10. $l = strlen($str) - $i;
  11. $ext = substr($str,$i+1,$l);
  12. return $ext;
  13. }
  14.  
  15. //This variable is used as a flag. The value is initialized with 0 (meaning no
  16. // error found)
  17. //and it will be changed to 1 if an errro occures.
  18. //If the error occures the file will not be uploaded.
  19. $errors=0;
  20. //checks if the form has been submitted
  21. if(isset($_POST['Submit']))
  22. {
  23. // lấy tên file upload
  24. $image=$_FILES['image']['name'];
  25. // Nếu nó không rỗng
  26. if ($image)
  27. {
  28. // Lấy tên gốc của file
  29. $filename = stripslashes($_FILES['image']['name']);
  30. //Lấy phần mở rộng của file
  31. $extension = getExtension($filename);
  32. $extension = strtolower($extension);
  33. // Nếu nó không phải là file hình thì sẽ thông báo lỗi
  34. if (($extension != "jpg") && ($extension != "jpeg") && ($extension !=
  35. "png") && ($extension != "gif"))
  36. {
  37. // xuất lỗi ra màn hình
  38. echo '<h1>Đây không phải là file hình!</h1>';
  39. $errors=1;
  40. }
  41. else
  42. {
  43. //Lấy dung lượng của file upload
  44. $size=filesize($_FILES['image']['tmp_name']);
  45. if ($size > MAX_SIZE*1024)
  46. {
  47. echo '<h1>Vượt quá dung lượng cho phép!</h1>';
  48. $errors=1;
  49. }
  50.  
  51. // đặt tên mới cho file hình up lên
  52. $image_name=time().'.'.$extension;
  53. // gán thêm cho file này đường dẫn
  54. $newname="images/".$image_name;
  55. // kiểm tra xem file hình này đã upload lên trước đó chưa
  56. $copied = copy($_FILES['image']['tmp_name'], $newname);
  57. if (!$copied)
  58. {
  59. echo '<h1> File hình này đã tồn tại </h1>';
  60. $errors=1;
  61. }}}}
  62.  
  63. if(isset($_POST['Submit']) && !$errors)
  64. {
  65. echo "<h1>File hình đã được Upload thành công </h1>";
  66. }
  67.  
  68. ?>
  69.  
  70. <!-- nhớ đặt enctype to "multipart/frm-data"
  71. và sử dụng input type "file" -->
  72. <form name="newad" method="post" enctype="multipart/form-data"
  73. action="">
  74. <table>
  75. <tr><td><input type="file" name="image"></td></tr>
  76. <tr><td><input name="Submit" type="submit" value="Upload image">
  77. </td></tr>
  78. </table>
  79. </form>

code php nhé up hinh tốt nhất

Đag dùng js :))

31.05.2018 / 00:11
minhmon
Bài đăng: 25
Member
Koollzboy đã viết

Đag dùng js :))

ok sẽ có js ngày mà

08.06.2018 / 08:38
minhmon
Bài đăng: 25
Member
bnduongdz đã viết

.éo khác gì tui soi :) Vẫn đel chạy

CSS
  1. [xcode]</style>
  2. <script src="http://oside.tk/js/jquery.js"></script>
  3.  
  4. <meta name="theme-color" content="#39434D"><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5.  
  6.  
  7.  
  8. <meta name="mobile-web-app-capable" content="yes">
  9. <meta name="apple-mobile-web-app-capable" content="yes">
  10. <link rel="shortcut icon" href="https://botvn.me/img/like_tren.jpg">
  11. <script src="http://rules.quantcount.com/rules-p-T-j7d64hMUWHE.js"></script><script src="http://edge.quantserve.com/quant.js" async="" type="text/javascript"></script><script async="" src="//www.google-analytics.com/analytics.js"></script><script src="/files/1005357/jquery.js"></script>
  12. </style>[/xcode]