Uploader Script

Discussion in 'Gaming' started by AgileLemon, Dec 13, 2005.

  1. AgileLemon

    AgileLemon Senior Member

    Posts:
    1,590
    Likes Received:
    0
    Joined:
    Aug 9, 2005
    I am looking to open my very own file sharing (free uploader) site. Please dont ask if i know what it involves i know... All i need is a FREE uploader script WITH status bar :) If you have any links please post them :)
     
  2. Phantasy

    Phantasy Senior Member

    Age:
    35
    Posts:
    1,914
    Likes Received:
    0
    Joined:
    Aug 18, 2005
    Location:
    Ontario, Canada
    Here you go ^_^

    Code:
    <html>
    
    <head>
    <title>Upload File</title>
    </head>
    
    <form action="upload.php" method="post" enctype="multipart/form-data">
    Browse a File to Upload:
    
    <input type="file" name="filetoupload">
    
    <input type="hidden" name="MAX_FILE_SIZE" value="<?echo $size_bytes; ?>">
    
    
    <input type="Submit" value="Upload File">
    </form>
    
    <?php
    /*
    Author:  Mohammed Ahmed(M@king)
    E-mail:  m at maaking dot com
    WWW   :  [url]http://www.maaking.com[/url]
    */
    //**********************************************************************//
    //  $_FILES['filetoupload']  is the value of                            //
    // file field from the form. <input type="file" name="filetoupload">    //
    //**********************************************************************//
    
    // this is the upload dir where files will go.
    //Don't remove the /
    //Chmod it (777)
    $upload_dir = "images/";   //change to whatever you want.
    // files less than 1MB
    $size_bytes = 1048576; //bytes  will be uploaded
    $limit_file_type = "no"; //Do you want to limit the types of files uploaded. (yes/no)
    // specify file types.
    $allowed_file_type = array('image/gif',
                              'image/pjpeg',
                              'image/jpeg',
                              'image/png',
                              'image/jpg');
    
             //check if the directory exist or not.
             if (!is_dir("$upload_dir")) {
         die ("The directory [b]($upload_dir)[/b] doesn't exist");
             }
             //check if the directory is writable.
             if (!is_writeable("$upload_dir")){
                die ("The directory [b]($upload_dir)[/b] is NOT writable, Please Chmod (777)");
             }
    
    //Check first if a file has been selected
    //is_uploaded_file('filename') returns true if
    //a file was uploaded via HTTP POST. Returns false otherwise.
    if (is_uploaded_file($_FILES['filetoupload']['tmp_name']))
    {//begin of is_uploaded_file
    
            //Get the Size of the File
            $size = $_FILES['filetoupload']['size'];
            //Make sure that $size is less than 1MB (1000000 bytes)
            if ($size > $size_bytes)
            {
                echo "File Too Large. File must be [b]$size_bytes[/b] bytes.";
                exit();
            }
                 //check file type
            if (($limit_file_type == "yes") && (!in_array($_FILES['filetoupload']['type'],$allowed_file_type)))
            {
                echo"wrong file type";
                exit();
            }
    
            // $filename will hold the value of the file name submetted from the form.
            $filename =  $_FILES['filetoupload']['name'];
            // Check if file is Already EXISTS.
            if(file_exists($upload_dir.$filename)){
                echo "Oops! The file named [b]$filename [/b]already exists";
                exit();
            }
    
            //Move the File to the Directory of your choice
            //move_uploaded_file('filename','destination') Moves afile to a new location.
            if (move_uploaded_file($_FILES['filetoupload']['tmp_name'],$upload_dir.$filename)) {
    
               //tell the user that the file has been uploaded and make him alink too;).
               echo "File (<a href=$upload_dir$filename>$filename</a>) uploaded!";
               exit();
    
            }
            else
            {
                //Print error
                echo "There was a problem moving your file";
                exit();
            }
    }//end of is_uploaded_file
    
    
    ?>
    
    
    
     
  3. Artico

    Artico Well-Known Member

    Posts:
    70
    Likes Received:
    0
    Joined:
    Nov 29, 2005
    Hope you got over 100gb of bandwidth atleast.... :) I have used up 50gb in 2 weeks!
     
  4. AgileLemon

    AgileLemon Senior Member

    Posts:
    1,590
    Likes Received:
    0
    Joined:
    Aug 9, 2005
    its dedicated my firend :) i got unlimited bandwidth... although unlimited is impossible i get what i am promised :) if not... i get my money back :).
     
  5. AgileLemon

    AgileLemon Senior Member

    Posts:
    1,590
    Likes Received:
    0
    Joined:
    Aug 9, 2005
    thanks but i cant see anything like a status bar in there :S
     
  6. AgileLemon

    AgileLemon Senior Member

    Posts:
    1,590
    Likes Received:
    0
    Joined:
    Aug 9, 2005
    i am now offering 100credits to the person who finds the best script :)
     
  7. mC² flexik

    mC² flexik Well-Known Member

    Age:
    33
    Posts:
    1,249
    Likes Received:
    0
    Joined:
    Nov 13, 2005
    Location:
    London, UK
    I think I have one but without the upload bar, I'll find one eventually though :)
     
  8. ihatebeans

    ihatebeans Senior Member

    Posts:
    2,502
    Likes Received:
    0
    Joined:
    Apr 20, 2005
    Location:
    PA
    i have one but its in a folder i just msged you on msn
     
  9. Mirish

    Mirish Member

    Age:
    37
    Posts:
    18
    Likes Received:
    0
    Joined:
    Dec 14, 2005
    Location:
    UK, From Texas
    That script is awesome guys. Agile have you set up the site yet?
     
  10. AgileLemon

    AgileLemon Senior Member

    Posts:
    1,590
    Likes Received:
    0
    Joined:
    Aug 9, 2005
    yes, but its not yet ready for public use :) its configured but i have to change servers :)
     

Share This Page