1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP Upload Script Help!

Discussion in 'PHP' started by Tropica, Nov 15, 2007.

  1. #1
    Hey

    I need a script that will:

    1. Allow the user to upload 1 image only
    2. accept gif, jpeg, png and bmp
    3. convert the gif/jpeg/png/bmp to .jpg
    4. resize the image automatically
    4. automatically save the file in a specified folder automatically renaming the file e.g. to photo.jpg (and will overwrite that file if another is uploaded)

    Does anyone know of such a script? or can someone make one for me?

    Thanks guys :)
     
    Tropica, Nov 15, 2007 IP
  2. clinton

    clinton Well-Known Member

    Messages:
    2,166
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    110
    #2
    clinton, Nov 15, 2007 IP
    Tropica likes this.
  3. msaqibansari

    msaqibansari Peon

    Messages:
    84
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    msaqibansari, Nov 15, 2007 IP
    Tropica likes this.
  4. Tropica

    Tropica Notable Member

    Messages:
    2,431
    Likes Received:
    128
    Best Answers:
    0
    Trophy Points:
    230
    #4
    cheers chaps, green coming your way :)
     
    Tropica, Nov 15, 2007 IP
  5. Tropica

    Tropica Notable Member

    Messages:
    2,431
    Likes Received:
    128
    Best Answers:
    0
    Trophy Points:
    230
    #5
    last bit of help?

    I have this:
    
    
    <?php
    $target = "upload/";
    $target = $target . basename( $_FILES['uploaded']['name']) ;
    $ok=1;
    
    if(move_uploaded_file($_FILES['uploaded']['tmp_name'], "upload/photo.jpg"))
    
    {
    echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
    }
    else {
    echo "Sorry, there was a problem uploading your file.";
    }
    ?>
    
    
    PHP:
    Which works great, and you can upload jpg, gif, png etc...

    But i cant get them to resize on upload :(

    I just need to define height of 156px on upload, anyone any ideas? Maybe (hopefully) just a line of added code?

    Thanks! :)
     
    Tropica, Nov 16, 2007 IP
  6. clinton

    clinton Well-Known Member

    Messages:
    2,166
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    110
    #6
    I found this
    http://blazonry.com/scripting/upload-size.php

    I never saw or used this function beforem, system("pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$newfile");

    check out the downloads and stuff on the page, seems really good for what you want.

    hope this helps
     
    clinton, Nov 16, 2007 IP
  7. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #7
    GD does it for you.

    imagecopyresampled() and a bit of maths to scale images correctly or you can use one of the many examples at http://phpclasses.org
     
    krt, Nov 16, 2007 IP