Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2005
    Posts
    1,411
    Tokens
    0

    Latest Awards:

    Default Php Help Needed ASAP.

    I was wondering do you know how to restrict the image if it does not complie with the dimensions i want to set.

    <form enctype="multipart/form-data" action="uploader.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    <input type="submit" value="Upload File" />
    </form>

    Ty

    - Matt
    Last edited by lMattz; 06-07-2006 at 06:59 PM.

  2. #2
    Join Date
    Nov 2004
    Location
    London, UK
    Posts
    233
    Tokens
    66
    Habbo
    tularis

    Latest Awards:

    Default

    Use "if" statements in the php file or add a new variable in the form.

    Use something like

    <input type="hidden" name "MAX_DIMENSIONS" width="100" height="100" value="MAX_IMAGE" />

    and then get the php file to check the dimensions do not exceed the values above
    Last edited by tularis; 09-07-2006 at 03:44 PM.

  3. #3
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    It isn't very secure storing restrictions etc. in hidden fields, as malicious users could change these values. Your best option would be to have the restrictions stored in a variable inside your PHP script, and then checking the size of the image (http://uk.php.net/getimagesize) against the limitations you've set.
    kinda quit.

  4. #4
    Join Date
    Feb 2005
    Location
    Leicestershire / Sheffield
    Posts
    685
    Tokens
    0

    Default

    You need to do it in the PHP, not the HTML form.

    Something like this:

    PHP Code:
    $max_height "100";
    $max_width "100";
    if (
    $max_width && $max_height) {
    list(
    $width$height$type$w) = getimagesize($_FILES['file']['tmp_name']);
    if(
    $width $max_width || $height $max_height){
    print 
    "File height and/or width are too big!";
    exit;
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •