Upload Form

Status
Not open for further replies.

scorch94

Member
Messages
228
Reaction score
0
Points
16
I am giving 500 credits to anyone who does this job. I need a simple upload form in PHP.
Let the page be called upload.php. It should contain a browse form and Upload! button. The only extension allowed to be uploaded is .pas

The file intended to be uploaded should be contained in the same directory as upload.php

Thanks in advance!
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
PHP:
    <?php
    
    if (empty($_POST['upload'])) {
        echo '
<form name="upload" enctype="multipart/form-data" method="POST" action="'.$_SERVER['REQUEST_URI'].'">
<input type="file" name="file" size="13" value="">
<br /><input type="submit" name="upload" value="Upload">
</form>
';
    } else {
        //these variables should be self explanatory
        $yourdomain = 'http://www.yourdomain.com/';
        $uploaddir = './';
        $filename = $_FILES['file']['name'];
        $filesize = $_FILES['file']['size'];
        $tmpname_file = $_FILES['file']['tmp_name'];
        
        
        $filetype=substr($filename,-4);
        if($filetype==".pas") //now we check the file extension, make sure its a pas file  {
        if($filesize > '5000000')  //set this to something realistic, pas files should be small
        {
            echo "Way too big!!";
        } else {
            move_uploaded_file($tmpname_file, "$uploaddir$filename");
            echo "Successful.<br /><b>URL: </b><textarea rows='1' cols='13'>".$yourdomain.$uploaddir.$filename."</textarea>";
        }
    } else {
        echo "Not a .pas file";
    }
}
?>
 

scorch94

Member
Messages
228
Reaction score
0
Points
16
Didn't work out :( I will ask one person tho, so if he makes it first... he gets credits :)

I get some errors... syntax errors or so.

Good luck with the race :)
Edit:
I changed my mind. Anyway you do it or not you can be ensured you have 300 credits :) If you do it... 500.

I will give you 300 creds at least because you put your work in this and I appreciate it ;)
 
Last edited:

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
PHP:
    <?php

if ( empty( $_POST['upload'] ) )
{
    echo '
<form name="upload" enctype="multipart/form-data" method="POST" action="' . $_SERVER['REQUEST_URI'] . '">
<input type="file" name="file" size="13" value="">
<br /><input type="submit" name="upload" value="Upload">
</form>
';
}
else
{
    // these variables should be self explanatory
    $yourdomain = 'http://www.yourdomain.com/';
    $uploaddir = './';
    $filename = $_FILES['file']['name'];
    $filesize = $_FILES['file']['size'];
    $tmpname_file = $_FILES['file']['tmp_name'];

    $filetype = substr( $filename, -4 );
    if ( $filetype == ".pas" ) // now we check the file extension, make sure its a pas file  {
    {
        if ( $filesize > '5000000' ) // set this to something realistic, pas files should be small
            {
                echo "Way too big!!";
        }
        else
        {
            move_uploaded_file( $tmpname_file, "$uploaddir$filename" );
            echo "Successful.<br /><b>URL: </b><textarea rows='1' cols='13'>" . $yourdomain . $uploaddir . $filename . "</textarea>";
        }
    }
    else
    {
        echo "Not a .pas file";
    }
}

?>

Corrected version. Its not easy to code inside vBulletin =(
 

mr kennedy

Member
Messages
524
Reaction score
1
Points
18
Slothie's right... if you are to code vBulletin, the source code will be coming in handy(it comes when you buy a license). you will have the MySQL table codings, the vB hooks and all those stuff
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
Slothie's right... if you are to code vBulletin, the source code will be coming in handy(it comes when you buy a license). you will have the MySQL table codings, the vB hooks and all those stuff

You misunderstood me. I meant its hard to code inside these textboxes. vBulletin itself is pretty easy to code in.
 

Christopher

Retired
Messages
14,659
Reaction score
8
Points
0
Locked.
You can do it yourself by clicking Thread Tools anc then close thread
 
Status
Not open for further replies.
Top