Search code examples
phpimageimage-processingimage-uploadinggdlib

How to upload high resolution image to folder using gd library or any method?


How to upload high resolution image to folder using gd library or any method? Any help appreciated.

    mkdir("../Connectors/upload_images/$album_name/");

    $file_tmpname=$_FILES['is_albimg']['tmp_name'];

    $file_name=$_FILES['is_albimg']['name'];

    $file_nm=explode('.',$file_name);

    //print_r($file_nm); die();

    $fname2=$file_nm[0].time().".".$file_nm[1];

    $hash = hash('md5', $fname2);

    $fname = $hash.".".$file_nm[1];

                $up='../Connectors/upload_images/'.$album_name.'/'.$fname;

    //echo $up; die();

    move_uploaded_file($file_tmpname,$up) or die();

Solution

  • The PHP upload processing does not know anything about imges, much less about resolution. It just handles files.

    If you want to create a scaled-down preview from an uploaded image (I gues that's what you want; your actual question is less than clear), get yourself familiar with GD, and create the image.

    Check the docs: http://php.net/manual/en/book.image.php

    Specifically, imagecopyresampled().

    Please note that the code sample posted here contains grave security issues; I hope that is just an example and not production code. Check out the PHP manual on handling uploaded files here: http://www.php.net/manual/en/features.file-upload.php