[uploader] / uploader.php Repository:

View of /uploader.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (download) (annotate)
Mon Jan 1 15:25:20 2007 EST (3 years, 8 months ago) by jerome
File size: 1717 byte(s)
Spaces -> Tabs

<?php include "include.php" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
    <link rel="stylesheet" type="text/css" href="style.css" />
    <title>Status</title>
    </head>
<body>
<?php
    
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
    // of $_FILES.

    
$remotefile basename($_POST['remotefile']);
    if(
$remotefile == "") {
    
$uploadfile basename($_FILES['uploadfile']['name']);
    } else {
    
$uploadfile "$remotefile";
    }

    if(
$uploadfile == "") {
    echo 
"You should enter a File name before clicking upload.";
    return;
    }

    if(
$_FILES['uploadfile']['size'] == 0) {
    echo 
"You can't specify a directory to upload, nor files of the size of 0 byte aka Empty files.";
    return;
    }

    if(
file_exists($uploaddir $uploadfile)) {
    do {
        
$randfile rand();
        
$randfile $randfile "_" $uploadfile;
    } while(
file_exists($uploaddir $randfile));
    echo 
"<p>The filename '<a href='$uploadfile'>" basename($uploadfile) ."</a>' is already in use,";
    echo 
" so, your file was renamed to include this<br/>";
    echo 
"random number to make it unique: $randfile</p>";
    
$uploadfile $randfile;
    }
    
$uploadfile $uploaddir $uploadfile;

    
umask(0);
    
move_uploaded_file($_FILES['uploadfile']['tmp_name'], $uploadfile);
    
chmod($uploadfile0644);

    echo 
'<pre>';
    echo 
'Debug:';
    
print_r($_FILES);

    echo 
'</pre>';

    if(
$_FILES['error'] == 0) {
    
$dellink sha1($delkey basename($_FILES['uploadfile']['name']));
    echo 
"<p>";
    echo 
"OK --> <a href='$uploadfile'>Link to the file</a><br/>";
    echo 
"<a href='udeleter.php?file=" $dellink "'>Link to delete this file</a><br/>";
    echo 
"</p>";
    }
?>
</body>
</html>

TiCPU
ViewVC Help
Powered by ViewVC 1.0.1