gi8ri7
JAMES_RODRIGUEZ, # JAMES_RODRIGUEZ (10.02.2019 / 18:19)
Saytga rasm yuklash kodini yozib yuboringlar ++
Kod · PHP105 qator
$upload_file_size = 300;



    if (isset($_POST['submit'])) {

        require_once ('../incfiles/lib/class.upload.php');

        $handle = new upload($_FILES['imagefile']);

        if ($handle->uploaded) {

            $name_file = time() . '_' . mt_rand(100, 999);

            $handle->file_new_name_body = $name_file;

            $handle->allowed = array('image/jpeg', 'image/gif', 'image/png');

            $handle->file_max_size = 300 * $upload_file_size;

            $handle->file_overwrite = true;

            $handle->image_convert = 'png';

            $handle->process('../files/images/');

            if ($handle->processed) {

            $handle->file_new_name_body =$name_file . '_preview';

            $GetImageSize = GetImageSize('../files/images/' . $name_file . '.png');

                $handle->file_overwrite = true;

                $handle->image_resize = true;

               $handle->image_ratio_crop = true;

               $x_ratio = 80 / $GetImageSize[0];

            $y_ratio = 80 / $GetImageSize[1];

if (($GetImageSize[0] <= 80) && ($GetImageSize[1] <= 80)) {

                $handle->image_x = $GetImageSize[0];

                $handle->image_y = $GetImageSize[1];

            } else if (($x_ratio * $GetImageSize[1]) < 80) {

                $handle->image_y = ceil($x_ratio * $GetImageSize[1]);

                $handle->image_x = 80;

            } else {

                $handle->image_x = ceil($y_ratio * $GetImageSize[0]);

                $handle->image_y = 80;

            }

$handle->image_convert = 'png';

$handle->process('../files/images/');

if ($handle->processed) {

        echo '<div class="phdr"><b>Rasm yuklash</b></div>' .

        '<div class="gmenu">Rasm yuklandi!</div>' .

        '<div class="phdr"><a href="upload_img.php">Orqaga</a></div>';

}else

echo functions::display_error($handle->error, '<a href="upload_img.php">Orqaga</a>');

} else

                echo functions::display_error($handle->error, '<a href="upload_img.php">Orqaga</a>');

$handle->clean();

} else {

            echo functions::display_error('Fayl tanlanmadi', '<a href="upload_img.php">Orqaga</a>');

        }

    } else {

        echo '<div class="phdr"> <a href="faq.php?act=tags">ВВ-kodlar</a> | <b>Rasm yuklash</b></div>' .

        '<form enctype="multipart/form-data" method="post" action="upload_img.php?img"><div class="list1">' .

        'Rasmni tanlang:<br /><input type="file" name="imagefile" value="" />' .

        '<input type="hidden" name="MAX_FILE_SIZE" value="' . (300 * $upload_file_size) . '" />' . '<br />' .

        '<p><input type="submit" name="submit" value="Yuklash" /></p></div></form>' .

        '<div class="list2"><small>Yuklash uchun ruxsat etilgan formatlar: JPG, JPEG, PNG, GIF<br />' .

        'Rasm hajmi ' . $upload_file_size . 'kb dan oshmasligi lozim.</small></div>';