[PHP]Upload a file in php menu

User Tag List

Results 1 to 1 of 1
  1. #1
    visitor's Avatar Contributor
    Reputation
    174
    Join Date
    Mar 2008
    Posts
    307
    Thanks G/R
    16/15
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [PHP]Upload a file in php

    Hi!

    Here is a php code made by me to upload files.

    PHP Code:
    <?php
    /*
    Upload form & script in one.
    By visitor from MMOWNED
    */
    //Settings
    $maxsize 2097152//in bytes
    $upload_folder "uploads/"//You have to create it yourself

    //Upload script
    if(isset($_FILES["file"])){
        if (
    $_FILES["file"]["size"] < $maxsize){
            if (
    $_FILES["file"]["error"] > 0){        
                echo 
    "Return Code: " $_FILES["file"]["error"] . "<br />";        
            }else {
                echo 
    "Filename: " $_FILES["file"]["name"] . "<br>
                Type: " 
    $_FILES["file"]["type"] . "<br>
                Size: " 
    . ($_FILES["file"]["size"] / 1024) . " Kb<br>";
                if (
    file_exists($upload_folder $_FILES["file"]["name"])){
                    echo 
    $_FILES["file"]["name"] . " already exists. ";
                }else {
                    
    move_uploaded_file($_FILES["file"]["tmp_name"], $upload_folder $_FILES["file"]["name"]);
                    echo 
    '<a href="' $upload_folder $_FILES["file"]["name"] . '">Download link</a>';                    
                }
            }
        }else {
          echo 
    "The file's too big";
        }
    }else {
        echo 
    '
            <html>
            <body>
            <form action="index.php" method="post" enctype="multipart/form-data">
            <strong>Filename:</strong><br>
            <input type="file" name="file" id="file" />
            <br />
            <input type="submit" name="submit" value="Submit" />
            </form>
            </body>
            </html>'
    ;
    }
    ?>
    Name it to index.php, use your settings, have fun.

    DO NOT FORGET:
    • to create the folder you want the script upload the files to
    • to edit <form action="index.php" part of the code, if you want to rename the file.
    • All credit goes to me (banviktor):wave:

    Last edited by visitor; 05-24-2009 at 12:10 PM.
    Hey I just met you

    [PHP]Upload a file in php

Similar Threads

  1. Windows Form upload data file by HTTP POST
    By secureecs in forum Programming
    Replies: 1
    Last Post: 10-26-2009, 08:20 PM
  2. Upload of file failed ????
    By Gummibär in forum Community Chat
    Replies: 2
    Last Post: 07-01-2008, 10:10 AM
  3. [Help] Please upload your file fast ;)
    By INS4N3K1LL in forum World of Warcraft Emulator Servers
    Replies: 8
    Last Post: 05-16-2008, 12:26 PM
  4. File splitting software (good for uploading big files)
    By Marlo in forum World of Warcraft Bots and Programs
    Replies: 15
    Last Post: 06-25-2007, 07:20 AM
All times are GMT -5. The time now is 02:17 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search