8
Ok. My webhost is
http://www.1go.dk and according to them this php script will work for uploading files:
<?php
// general configuration
$upload_path = "docs/"; // path to your upload directory
$extval_use = 1; // turns on/off extension validation
// forbidden extensions
$extval = array("php", "php3", "php4", "asp", "bat", "exe",
"com", "jsp", "cfml", "shtml", "dtcl");
$filesize_limit_use = 1; // turns on/off size check
$filesize_limit = 200; // file size limit (in kB)
// language customization
$message["fileisbig"] = "Filen er større end den tilladte størrelse på ("
. $filesize_limit . "kB)";
$message["invext"] = "Filer af denne type kan ikke uploades!";
$message["incomplete"] = "Upload lykkedes ikke.";
$message["complete"] = "Upload er fuldført.";
$message["uploadbutton"] = "Upload";
$message["uploadtxt"] = "Fil, der skal uploades: ";
$message["fileexists"] = "Filen findes i forvejen!";
$rc = 0;
if ( isset($HTTP_POST_VARS["upload"]) ) {
$orig_name = $HTTP_POST_FILES['userfile']['name'];
$filename = ereg_replace("[^a-z0-9._]", "",
ereg_replace (" ", "_",
ereg_replace("%20", "_",
strtolower($orig_name))));
// <filesize>
if($filesize_limit_use=1) {
$filesize = $HTTP_POST_FILES['userfile']['name'] / 1024; //filesize in kB
if($filesize_limit < $filesize) {
echo "<p><font color='red'><center>"
. $message["fileisbig"]."</font></center></p>";
$rc = 1;
}
}
// </filesize>
if ( $rc == 0 ) {
// <extension_validate>
if($extval_use=1) {
$extget = substr( strrchr($filename, "."), 1);
$found = in_array($extget, $extval);
if ( $found ) {
echo "<p><font color='red'><center>"
. $message["invext"]."</font></center></p>";
$rc = 2;
}
}
// </extension_validate>
}
if ( $rc == 0 ) {
// <file exists verification>
echo "<p><center>Trying to upload to: "
. $upload_path . $filename . "</center></p>n";
if ( file_exists($upload_path.$filename) ) {
echo "<p><font color='red'><center>"
. $message["fileexists"]."</font></center></p>";
} else {
if( move_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'],
$upload_path.$filename) ) {
echo "<p><center>" . $message["complete"]."</center></p>";
} else {
echo "<p><font color='red'><center>"
. $message["incomplete"]."</font></center></p>";
}
}
// </file exists verification>
}
}
echo "
<html><head></head><title>Upload-script</title><body>
<h3>Upload filer</h3><br><br>
<form enctype='multipart/form-data' method='post' action=''>
<input type='hidden' name='action' value='upload'>
<table frame=box rules=none border=0 cellpadding=2
cellspacing=0 align='center'>
<tr>
<td>".$message["uploadtxt"]."</td>
<td><input type='file' name='userfile'> <input type='submit' name ='upload'
value='".$message["uploadbutton"]."'></td>
</tr>
<tr>
<td></td>
<td></td>
<tr>
</table>
</form>";
?>
Is there anyway I can modify the upload script in XOOPS so that it will work like this one?