Advertisement
Guest User

uploadding 4 files

a guest
Jan 26th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1.  
  2. $file1 = mysqli_real_escape_string($con, $_POST['file1']);
  3. $file2 = mysqli_real_escape_string($con, $_POST['file2']);
  4. $file3 = mysqli_real_escape_string($con, $_POST['file3']);
  5. $file4 = mysqli_real_escape_string($con, $_POST['file4']);
  6.  
  7.  
  8.  
  9. // DIVICION DE FILES
  10. $ext = 'jpeg,gif,png';
  11. $tPermitidoKB = 1000;
  12. $tipo = explode('/', $_FILES['file1']['type']);
  13. $file_ext = $tipo[1];
  14. //colocando imagen por default
  15. if (trim($_FILES['file1']['name']) != '') {
  16. //dando un nombre al archivo
  17. $file1 = $filenam.rand() .'.' . $file_ext;
  18. //confirmando que el archivo es permitido
  19. if (!strstr($ext, $file_ext)) {
  20. header('Location: nutricion_publicar.php?msn=Archivo no permitido');
  21. exit();
  22. }
  23. //Tamaño del archivo
  24. if ($_FILES['file1']['size'] / 1024 > $tPermitidoKB) {
  25. header('Location: nutricion_publicar.php?msn=Archivo excede el tamaño permitido');
  26. exit();
  27. }
  28. $archivo = true;
  29. } else {
  30. $file1 = '';
  31. $archivo = false;
  32. }
  33.  
  34. // DIVICION DE FILES
  35. $ext = 'jpeg,gif,png';
  36. $tPermitidoKB = 1000;
  37. $tipo = explode('/', $_FILES['file2']['type']);
  38. $file_ext = $tipo[1];
  39. //colocando imagen por default
  40. if (trim($_FILES['file2']['name']) != '') {
  41. //dando un nombre al archivo
  42. $file2 = $filenam.rand() .'.' . $file_ext;
  43. //confirmando que el archivo es permitido
  44. if (!strstr($ext, $file_ext)) {
  45. header('Location: nutricion_publicar.php?msn=Archivo no permitido');
  46. exit();
  47. }
  48. //Tamaño del archivo
  49. if ($_FILES['file2']['size'] / 1024 > $tPermitidoKB) {
  50. header('Location: nutricion_publicar.php?msn=Archivo excede el tamaño permitido');
  51. exit();
  52. }
  53. $archivo = true;
  54. } else {
  55. $file2 = '';
  56. $archivo = false;
  57. }
  58.  
  59. // DIVICION DE FILES
  60. $ext = 'jpeg,gif,png';
  61. $tPermitidoKB = 1000;
  62. $tipo = explode('/', $_FILES['file3']['type']);
  63. $file_ext = $tipo[1];
  64. //colocando imagen por default
  65. if (trim($_FILES['file3']['name']) != '') {
  66. //dando un nombre al archivo
  67. $file3 = $filenam.rand() .'.' . $file_ext;
  68. //confirmando que el archivo es permitido
  69. if (!strstr($ext, $file_ext)) {
  70. header('Location: nutricion_publicar.php?msn=Archivo no permitido');
  71. exit();
  72. }
  73. //Tamaño del archivo
  74. if ($_FILES['file3']['size'] / 1024 > $tPermitidoKB) {
  75. header('Location: nutricion_publicar.php?msn=Archivo excede el tamaño permitido');
  76. exit();
  77. }
  78. $archivo = true;
  79. } else {
  80. $file = '';
  81. $archivo = false;
  82. }
  83.  
  84.  
  85. // DIVICION DE FILES
  86. $ext = 'jpeg,gif,png';
  87. $tPermitidoKB = 1000;
  88. $tipo = explode('/', $_FILES['file4']['type']);
  89. $file_ext = $tipo[1];
  90. //colocando imagen por default
  91. if (trim($_FILES['file4']['name']) != '') {
  92. //dando un nombre al archivo
  93. $file4 = $filenam.rand() .'.' . $file_ext;
  94. //confirmando que el archivo es permitido
  95. if (!strstr($ext, $file_ext)) {
  96. header('Location: nutricion_publicar.php?msn=Archivo no permitido');
  97. exit();
  98. }
  99. //Tamaño del archivo
  100. if ($_FILES['file4']['size'] / 1024 > $tPermitidoKB) {
  101. header('Location: nutricion_publicar.php?msn=Archivo excede el tamaño permitido');
  102. exit();
  103. }
  104. $archivo = true;
  105. } else {
  106. $file = '';
  107. $archivo = false;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement