Visa ett inlägg
Oläst 2003-03-15, 15:26 #2
Filips avatar
Filip Filip är inte uppkopplad
Mycket flitig postare
 
Reg.datum: Jan 2003
Inlägg: 935
Filip Filip är inte uppkopplad
Mycket flitig postare
Filips avatar
 
Reg.datum: Jan 2003
Inlägg: 935
Här är ett PHP-script, som jag använder för att ladda upp filer via webbrowsern. Sen är det bara att lösenordskydda katalogen där scriptet ligger.



<?php

print "<html>
<head>
<title>Uploading a File</title>
</head>
<body>";


if ($myfile) {

$dirname = "filedownloads";
define(PATH, "/var/www/");

$filename = $myfile_name;

// check if they actually placed something in the file input
if ($filename != "")
{
// check if the directory exists
// if it doesnt exist, make the directory
if (!$dir = @opendir(PATH.$dirname))
// make the directory (sets chmod to 700)
mkdir(PATH.$dirname, 0770) or die("Error: could not make directory.");

// copy the file from the temporary upload position to where you want it
copy($myfile, PATH.$dirname."/".$filename) or die("Error: could not copy file.");

// delete the temporary uploaded file
unlink($myfile) or die("Error: could not delete uploaded file.");

// tell them it worked
echo $myfile_name." uploaded successfully.";
}
else
{
echo "You must select a file to upload.";
}

}

uploadForm();
print "</body>
</html>";


function uploadForm() {

print "

";
$freespace = round(disk_free_space("/var/www/")/1000);
$totalspace= round(disk_total_space("/var/www/")/1000);
#$df = round($df/1000);
print $freespace." kbytes of total ".$totalspace." kbytes available";
print "<form enctype=\"multipart/form-data\" method=post>
<input type=file name=myfile>


<input type=submit value=upload>

</form>";
}

?>
Filip är inte uppkopplad   Svara med citatSvara med citat