gi8ri7
JAMES_RODRIGUEZ, # JAMES_RODRIGUEZ (10.02.2019 / 18:19)
Saytga rasm yuklash kodini yozib yuboringlar ++
  1. $upload_file_size = 300;
  2.  
  3. if (isset($_POST['submit'])) {
  4. require_once ('../incfiles/lib/class.upload.php');
  5. $handle = new upload($_FILES['imagefile']);
  6. if ($handle->uploaded) {
  7. $name_file = time() . '_' . mt_rand(100, 999);
  8. $handle->file_new_name_body = $name_file;
  9. $handle->allowed = array('image/jpeg', 'image/gif', 'image/png');
  10. $handle->file_max_size = 300 * $upload_file_size;
  11. $handle->file_overwrite = true;
  12. $handle->image_convert = 'png';
  13. $handle->process('../files/images/');
  14. if ($handle->processed) {
  15. $handle->file_new_name_body =$name_file . '_preview';
  16. $GetImageSize = GetImageSize('../files/images/' . $name_file . '.png');
  17. $handle->file_overwrite = true;
  18. $handle->image_resize = true;
  19. $handle->image_ratio_crop = true;
  20. $x_ratio = 80 / $GetImageSize[0];
  21. $y_ratio = 80 / $GetImageSize[1];
  22. if (($GetImageSize[0] <= 80) && ($GetImageSize[1] <= 80)) {
  23. $handle->image_x = $GetImageSize[0];
  24. $handle->image_y = $GetImageSize[1];
  25. } else if (($x_ratio * $GetImageSize[1]) < 80) {
  26. $handle->image_y = ceil($x_ratio * $GetImageSize[1]);
  27. $handle->image_x = 80;
  28. } else {
  29. $handle->image_x = ceil($y_ratio * $GetImageSize[0]);
  30. $handle->image_y = 80;
  31. }
  32. $handle->image_convert = 'png';
  33. $handle->process('../files/images/');
  34. if ($handle->processed) {
  35. echo '<div class="phdr"><b>Rasm yuklash</b></div>' .
  36. '<div class="gmenu">Rasm yuklandi!</div>' .
  37. '<div class="phdr"><a href="upload_img.php">Orqaga</a></div>';
  38. }else
  39. echo functions::display_error($handle->error, '<a href="upload_img.php">Orqaga</a>');
  40. } else
  41. echo functions::display_error($handle->error, '<a href="upload_img.php">Orqaga</a>');
  42. $handle->clean();
  43. } else {
  44. echo functions::display_error('Fayl tanlanmadi', '<a href="upload_img.php">Orqaga</a>');
  45. }
  46. } else {
  47. echo '<div class="phdr"> <a href="faq.php?act=tags">ВВ-kodlar</a> | <b>Rasm yuklash</b></div>' .
  48. '<form enctype="multipart/form-data" method="post" action="upload_img.php?img"><div class="list1">' .
  49. 'Rasmni tanlang:<br /><input type="file" name="imagefile" value="" />' .
  50. '<input type="hidden" name="MAX_FILE_SIZE" value="' . (300 * $upload_file_size) . '" />' . '<br />' .
  51. '<p><input type="submit" name="submit" value="Yuklash" /></p></div></form>' .
  52. '<div class="list2"><small>Yuklash uchun ruxsat etilgan formatlar: JPG, JPEG, PNG, GIF<br />' .
  53. 'Rasm hajmi ' . $upload_file_size . 'kb dan oshmasligi lozim.</small></div>';