" /> Uploader Script [TUT]
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 3 123 LastLast
Results 1 to 10 of 29
  1. #1
    Join Date
    Jul 2006
    Location
    Athens
    Posts
    842
    Tokens
    0

    Default Uploader Script [TUT]

    Right, some of you have requested a better version of my pervious script so here it is.
    PHP Code:
    <?
    // Uploader Script made by E-Ash off Habbo UK
    // CONFIG
    $siteurl "http://www."//Must Include http:// and www. ending in where the images upload to with NO trailing slash
    $serverpath "images/";   // The End of the part above WITH trailing slash
    $urltoimages "$siteurl";  // Web address to where the images are accessible from.
    $maxsize "500000";     // Maximum size of the file people can upload
    $uniq uniqid("");
    // CONFIG END
    This is the start of your code. This is the configuration part.
    $siteurl - eg. http://www.habboxforum.com/images (NO TRAILING SLASH)
    $serverpath - eg. images/ (LEAVE TRAILING SLASH)
    $maxsize - The maximum size that a file can be befor it is restricted.

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

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

    This Is the Form where you select the file to upload. This is self-explanatory.
    PHP Code:
    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"
    This is the allowed files section. What ever files you want to allow to be uploaded just insert
    PHP Code:
    $allowedfiles[] = "EXTENTION"
    In both upper and lower case letters
    PHP Code:
    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>Please Note we do not take any responsibility of the images that you upload</p>";
    ?> 
    That is all the process stuff
    HTML Code:
    <!-- All the kinds of code you want to be outputed go here -->
    <img src="<?php echo "$urltoimages/$name" ?>">
    <br>Direct Link: <input name='direct' type='text' align='center' size='70' value='<?php echo "$urltoimages/$name" ?>'>
    <br>    BB Code:<input name='bbcode1' type='text' align='center' size='70' value='[img=<?php echo "$urltoimages/$name" ?>]'>
    <br>    BB Code:     <input name='bbcode2' type='text' align='center' size='70' value='[img]<?php echo "$urltoimages/$name" ?>[/img]'>
    <!-- End of all HTML Code -->
    This is all the output code of the Direct links and BB codes.
    You can add what ever you like as long its between the Hidden Text.

    PHP Code:
    <?php
               
        
    }

      }

    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>"; }
    }
    }
    ?>
    And that is the error message if it hasn't been uploaded.

    And thats now complete

    Full Version below
    __________________________________________________ _____________
    PHP Code:
    <?
    // Script Made By Ashley Cusack
    // CONFIG
    $siteurl "http://www."//Must Include http:// and www. ending in where the images upload to with NO trailing slash
    $serverpath "images/";   // The End of the part above
    $urltoimages "$siteurl";  // Web address to where the images are accessible from.
    $maxsize "500000";     // Maximum size of the file people can upload
    $uniq uniqid("");
    // CONFIG END

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

    if (
    $mode == "form") {
    echo 
    "<form enctype='multipart/form-data' method='post' action='upload.php?mode=upload'>\n";
    echo 
    "Upload file: <input type='file' name='file'>\n";
    echo 
    "<br><input type='submit' name='Submit' value='Upload'>\n";
    $bytesize "1000";
    $kb $maxsize/$bytesize;
    echo 
    "<br>Maximum File Size: $kb Kilobytes <em>($maxsize Bytes)</em>";
    }
    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>Please Note we do not take any responsibility of the images that you upload</p>";
    ?>
    <!-- All the kinds of code you want to be outputed go here -->
    <img src="<?php echo "$urltoimages/$name?>">
    <br>Direct Link: <input name='direct' type='text' align='center' size='70' value='<?php echo "$urltoimages/$name?>'>
    <br>    BB Code:<input name='bbcode1' type='text' align='center' size='70' value='[img=<?php echo "$urltoimages/$name?>]'>
    <br>    BB Code:     <input name='bbcode2' type='text' align='center' size='70' value='[img]<?php echo "$urltoimages/$name?>[/img]'>
    <!-- End of all HTML Code -->
    <?php
               
        
    }

      }

    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>"; }
    }
    }
    ?>


  2. #2
    Join Date
    Feb 2005
    Posts
    2,503
    Tokens
    0

    Latest Awards:

    Default

    Looks very good.
    Last edited by Matt.; 27-05-2007 at 08:52 PM.

  3. #3
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    His name is Ashley.

  4. #4
    Join Date
    Sep 2006
    Location
    Doncaster, UK
    Posts
    4,081
    Tokens
    0

    Latest Awards:

    Default

    His name is Ashely.

    Nice tut.
    Quote Originally Posted by Nain View Post
    i voted 'Not Sure' as im, not sure!

  5. #5
    Join Date
    Feb 2005
    Posts
    2,503
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    His name is Ashley.
    Lol, yeah. Sorry about my post before, I'm tired.

  6. #6
    Join Date
    Jul 2006
    Location
    Athens
    Posts
    842
    Tokens
    0

    Default

    Glad you like it, Hope this will come in useful for people


  7. #7
    Join Date
    Dec 2006
    Posts
    521
    Tokens
    0

    Default

    Correct me if im wrong, but you could upload bla.jpg.rar files and so on.

  8. #8
    Join Date
    Jul 2006
    Location
    Athens
    Posts
    842
    Tokens
    0

    Default

    Nope as it looks at the last 3 letters of the file


  9. #9
    Join Date
    Jun 2007
    Posts
    56
    Tokens
    0

    Default wa

    $siteurl - eg. http://www.habboxforum.com/images (NO TRAILING SLASH)
    $serverpath - eg. images/ (LEAVE TRAILING SLASH)

    wa u meen by NO TRAILInG Slash?

    and leave trailing slash

    and do u save the configuration file as config.php ?

  10. #10
    Join Date
    Aug 2006
    Location
    United Kingdom
    Posts
    3,843
    Tokens
    1,121

    Latest Awards:

    Default

    No trailing slash means dont put a / on the end
    leave trailing slash means put a / on the end, Dont bump this thread its a month old

Page 1 of 3 123 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
  •