Upload scritp

kdflash

Solid State Member
Messages
6
What i want on my site is users can upload actionscripts for other users to see.But i want it so i dont need to get it and manually put it on.I want it so when they fill it in and press submit then its their on the page for all to see.

How can i do this?
 
firstly, what server side language are you using?
asp, aspx, php, perl?
once we know the technologies you are using then we'll be able to help further.
 
OK, heres a quick example...
Code:
<?php
$function = $_GET['action'];
$currentloc = $HTTP_SERVER_VARS['DOCUMENT_ROOT'];

switch ($function)

    {
        case 'upload':
// In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of
// $_FILES.  In PHP earlier then 4.0.3, use copy() and is_uploaded_file()
// instead of move_uploaded_file

$uploaddir = '/var/www/html/upload/uploads/';
$uploadfile = $uploaddir. basename($_FILES['userfile']['name']);
print $currentloc;
print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
    print "File is valid, and was successfully uploaded. ";
    print "Here's some more debugging info:\n";
    print_r($_FILES);
} else {
    print "Possible file upload attack!  Here's some debugging info:\n";
    print_r($_FILES);
}
print "</pre>";

        break;
        default:
        print $currentloc;
        echo '<html><head><title>Upload files</title></head>\n
        <body bgcolor = "#78F0B4">
        <Font color = "#ff0000">
        <h2>Upload a file</h2>
        <form enctype="multipart/form-data" action="upload.php?action=upload" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000000">
Send this file: <input name="userfile" type="file"><br>
<input type="submit" value="Send File">
</form>';
        break;
    }
?>
I got the example from the PHP manual I think (it was quite a while ago and is now sitting on a server of mine).

This will send the file to an upload directory, all you have to do is pass the upload directory as a variable. I guess to browse through files you could use a loop to check if a file exists an then display it if it does, if it doesn't, finish the loop and end the page.

(hope this helps)
 
Back
Top Bottom