0

what I want to do is actually, I can upload with verot.net, but I couldn't resize. For Example: Normal Photo Size 1000x1500 save the photo I want twice. 1. Keep the size of the picture in its original form. 2. Get 470x705 without cropping the picture.

I could not figure out how to do this. Thank you in advance to those who can help.

<?php
if ($_POST['submit']) {
    
    $data['page_title'] = $_POST['page_title'];
    $data['page_url'] = permalink($_POST['page_url'] ? $_POST['page_url'] : $data['page_title']);

    if (mkdir(PATH . '/upload/pages/' . $data['page_url'], 0777)) {

        $handle = new upload($_FILES['page_image']);
        if ($handle->uploaded) {
            $handle->file_new_name_body = $data['page_url'] . '_' . rand(1, 9999);

            $handle->allowed = ['image/*'];
            $handle->process(PATH . '/upload/pages/' . $data['page_url']);
            if ($handle->processed) {
                $data['page_image'] = $handle->file_dst_name_body . '.' . $handle->file_dst_name_ext;
            } else {
                $error = $handle->error;
            }
        } else {
            $error = 'Picture Please!';
        }

    } else {
        $error = PATH . '/upload/pages/' . $data['page_url'] . ' Error!';
    }
}
Mesut Bla
  • 127
  • 1
  • 7

1 Answers1

2

I hope it works for you. you just have to leave the original as is and also create a thumb at once

<?php
if ($_POST['submit']) {
    
    $data['page_title'] = $_POST['page_title'];
    $data['page_url'] = permalink($_POST['page_url'] ? $_POST['page_url'] : $data['page_title']);

    if (mkdir(PATH . '/upload/pages/' . $data['page_url'], 0777)) {

        $handle = new upload($_FILES['page_image']);
        if ($handle->uploaded) {
            $handle->file_new_name_body = $data['page_url'] . '_' . rand(1, 9999);
            $handle->image_resize = true;
            $handle->image_ratio_crop = true;
            $handle->image_x = 470;
            $handle->image_y = 705;
            $handle->allowed = ['image/*'];
            $handle->process(PATH . '/upload/pages/' . $data['page_url']);
            if ($handle->processed) {
                $data['page_image'] = $handle->file_dst_name_body . '.' . $handle->file_dst_name_ext;
            } else {
                $error = $handle->error;
            }
        } else {
            $error = 'Picture Please!';
        }

    } else {
        $error = PATH . '/upload/pages/' . $data['page_url'] . ' Error!';
    }
}
Kaan Demir
  • 442
  • 2
  • 9