PHP Upload & Resize

Discussion in 'PHP' started by circuscircus, Jan 31, 2007.

Thread Status:
Not open for further replies.
  1. #1
    I want to take an image and resize it to 500 by 500 max IF it exceeds that in dimensions and then upload it, how can this be done?

    What I have:
    foreach ($_FILES["pictures"]["error"] as $key => $error) {
    $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
    $name = $_FILES["pictures"]["name"][$key];
    move_uploaded_file($tmp_name, $name);
    }
     
    circuscircus, Jan 31, 2007 IP
  2. DeViAnThans3

    DeViAnThans3 Peon

    Messages:
    785
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Myself I'ld solve this with PHP's GD library. However, not everyone has GD installed at his/her server. Before, please check if you have GD installed at your server, and let me know :) (open phpinfo(), and find "GD". See if status is installed)
     
    DeViAnThans3, Feb 1, 2007 IP
  3. alecs

    alecs Well-Known Member

    Messages:
    156
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    128
    #3
    You cannot test the size of the image before uploading it. This cannot be done within a browser, but only with a server-side script (like PHP) which requires the full file to test it.
     
    alecs, Feb 1, 2007 IP
  4. DeViAnThans3

    DeViAnThans3 Peon

    Messages:
    785
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It is a fact that you can't test the image size before uploading it, but afterwards the GD -if necessary- simple resizes the image ;)
     
    DeViAnThans3, Feb 2, 2007 IP
Thread Status:
Not open for further replies.