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!


Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Jul 2006
    Location
    Athens
    Posts
    842
    Tokens
    0

    Default Upload Script [TUT]

    I see alot of people requesting these at the moment. So i'll post mine.
    First make a folder called uploader.
    Then make one called images in side your uploader file.

    Make this file index.php
    PHP Code:
     <?
    // Script Made By Ashley Cusack
    // CONFIG
    $serverpath "images/";   // Path to where images should be upload the server.
    $urltoimages "http://sitename.domain/uploader/images";  // Web address to where the images are accessible from.
    $maxsize "500000";     // Example - 20000 is the same as 20kb
    $uniq uniqid("");
    // CONFIG END

    $mode $_GET['mode'];
    if (
    $mode == "") { $mode "form"; }

    if (
    $mode == "form") {
    echo 
    "<form enctype='multipart/form-data' method='post' action='?mode=upload'>\n";
    echo 
    "Upload file: <input type='file' name='file'>\n";
    echo 
    "<br><input type='submit' name='Submit' value='Upload'>\n";
    echo 
    "<br>Maximum File Size: $maxsizeb Bytes";
    echo 
    "<br>$file";
    }

    if (
    $mode == "upload") {
    $file $_FILES['file']['name'];
    $name time() . substr($file, -4);
     
    // If you add your own file types don't forget to add an uppercase version.
     
    $allowedfiles[] = "gif";
     
    $allowedfiles[] = "jpg";
     
    $allowedfiles[] = "jpeg";
     
    $allowedfiles[] = "jfef";
     
    $allowedfiles[] = "jpe";
     
    $allowedfiles[] = "png";
     
    $allowedfiles[] = "GIF";
     
    $allowedfiles[] = "JPG";
     
    $allowedfiles[] = "JPEG";
     
    $allowedfiles[] = "JFEF";
     
    $allowedfiles[] = "JPE";
     
    $allowedfiles[] = "PNG";
     
    $allowedfiles[] = "PDF";
     
    $allowedfiles[] = "pdf";
     
    $allowedfiles[] = "PSD";
     
    $allowedfiles[] = "psd";
     
    $allowedfiles[] = "bmp";
     
    $allowedfiles[] = "BMP";
     
    $allowedfiles[] = "tif";
     
    $allowedfiles[] = "tiff";
     
    $allowedfiles[] = "TIF";
     
    $allowedfiles[] = "TIFF";
     
    $allowedfiles[] = "dib";
     
    $allowedfiles[] = "DIB";


     if(
    $_FILES['file']['size'] > $maxsize)
     {
      print 
    "File size is too big - please reduce file size and try again.";
      }
      else {
      
    $path "$serverpath/" $name;
      foreach(
    $allowedfiles as $allowedfile) {
     
      if (
    $done <> "yes") {
      if (
    file_exists($path)) {
       echo 
    "A file with this name already exists - please rename the file and reupload.";
       exit;
      }
      }
     
      if (
    substr($file, -3) == $allowedfile) {
        
    move_uploaded_file($_FILES['file']['tmp_name'], "$path");
        
    $done "yes";
        echo 
    "<p>Your image has been successfully uploaded to our server and can be accessed using the URL provided below.</p>";
        echo 
    "<p><img src='$urltoimages/$name' border='0'>"
        echo 
    "<p>Direct Link: <input name='direct' type='text' size='75' value='$urltoimages/$name'></a></p>";
               
        }

      }

    if (
    $done <> "yes") { print "<p><b>Error:</b> Your image as not been uploaded becuase it is not a recognised image file. Please try again.</p>"; }
    }
    }

    ?>
    Where is says
    PHP Code:
    $urltoimages "http://sitename.domain/uploader/images";  // Web address to where the images are accessible from. 
    Change it to where your 'images' folder is. (Do not leave a trailing slash)

    Where is says
    PHP Code:
    $maxsize "500000";     // Example - 500000 is the same as 500kb 
    Change that to the maximum size you want in bytes.
    That uploader will host nearly every type of image. But you can add things like zips if you like by adding
    PHP Code:
    $allowedfiles[] = "zip";
    $allowedfiles[] = "ZIP"
    Below
    PHP Code:
     $allowedfiles[] = "DIB"
    Adn that concludes this tutorial.


  2. #2
    Join Date
    Nov 2006
    Location
    Cheshire.
    Posts
    730
    Tokens
    250

    Default

    Very nice TUT


    Give us an add like!

  3. #3
    Join Date
    Mar 2005
    Location
    Leeds
    Posts
    3,423
    Tokens
    0

    Latest Awards:

    Default

    Nice. On Uploadz rather than checking png, PNG it lowers the case when it checks so then you dont have problems if someone types in file.Png ect

    Only thing is this doesnt really teach people much, you need to add more comments into the coding so people dont just use it without learning.

  4. #4
    Join Date
    Feb 2006
    Location
    Sunderland
    Posts
    5,027
    Tokens
    1,306

    Latest Awards:

    Default

    nice tut, but you can only have a direct link.

    I was looking for one with bb, html, url etc..


  5. #5
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    3,285
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by iFx View Post
    nice tut, but you can only have a direct link.

    I was looking for one with bb, html, url etc..
    That wouldn't be difficult. Just use the normal HTML for forms, but use echo in PHP to echo the variables.



    i used to be NintendoNews. visit my blog or add me on twitter.
    need help with vista? i am a microsoft certified technology specialist in configuring windows vista and connected home integrator.. pm me for help!


    "I am the way, the truth, and the life. No one comes to the Father except through me"
    John 14:6 (NIV)


  6. #6
    Join Date
    Oct 2006
    Posts
    2,918
    Tokens
    946
    Habbo
    Verrou

    Latest Awards:

    Default

    Superb i really needed this but what happened?
    http://andrehamon.evenhosting.com/uploader
    Quote Originally Posted by Special-1k View Post
    How do you uninstall an internet? I want to uninstall my Google Chrome and
    get firefox but I never really got rid of an internet my dad usually did it for me.
    If you know how post below so I can do this.

  7. #7
    Join Date
    Aug 2006
    Location
    Manchester, UK
    Posts
    2,016
    Tokens
    141
    Habbo
    florx

    Latest Awards:

    Default

    Superb i really needed this but what happened?
    http://andrehamon.evenhosting.com/uploader
    Make sure the images folder is Chmod'ed to 777 then it can put the picture there!!!!

  8. #8
    Join Date
    Dec 2006
    Location
    None of your business!
    Posts
    2,492
    Tokens
    50

    Latest Awards:

    Default

    Nice Tutorial + rep if I can...

  9. #9
    Join Date
    Dec 2005
    Location
    Australia
    Posts
    693
    Tokens
    0

    Default

    Just a few notes for you to think about.

    What if the extension is more than 3 characters? ie: torrents; phps.

    Also, why not remove all the upper case versions of the extensions and add strtolower() to the filename, considering most are hosted on Linux boxes (Linux is case-sensitive filenames).
    XHTML, CSS, AJAX, JS, php, MySQL.

    --

    HxF moderators can't read timestamps.

  10. #10
    Join Date
    Oct 2006
    Posts
    2,918
    Tokens
    946
    Habbo
    Verrou

    Latest Awards:

    Default

    erm i chmod'd the images folder to 777 and it still doesn't work?
    Quote Originally Posted by Special-1k View Post
    How do you uninstall an internet? I want to uninstall my Google Chrome and
    get firefox but I never really got rid of an internet my dad usually did it for me.
    If you know how post below so I can do this.

Page 1 of 2 12 LastLast

Posting Permissions

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