Ik heb een script gevonden en aangepast om bestanden te uploaden naar mijn server. Nou werkt het wel, maar krijgen ik de volgende errors:
Notice: Use of undefined constant x - assumed 'x' in C:\Program Files\Apache Group\Apache2\htdocs\test\upload.php on line 32
Notice: Undefined index: x in C:\Program Files\Apache Group\Apache2\htdocs\test\upload.php on line 32
Notice: Use of undefined constant accept - assumed 'accept' in C:\Program Files\Apache Group\Apache2\htdocs\test\upload.php on line 46
Het script ziet er als volgt uit:
<?php
//CONFIGURE
$file = "/Program Files/Apache Group/Apache2/htdocs/test/uploaded/ ";
$limit = "1024000";
global $file;
global $limit;
print "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>SPeedY_B - File Upload</title>
<link rev="made" href="mailto:admin at speedyb co uk" />
<meta name="keywords" content="SPeedY_B, speedy, b, dave, php, html" />
<meta name="description" content="SPeedY_B - File Upload" />
<meta name="author" content="David G Kerry" />
<meta name="robots" content="ALL" />
<meta name="copyright" content="David G Kerry" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
font-family: verdana, arial, sans-serif;
font-size : 12px;
color: #000000;
background-color: #FFFFFF;
}
</style>
</head>
<body>
<div>
<?php
switch($_GET[x]) {
default:
print "Upload a file (Max $limit bytes)
<br /> <br />
<form action=\"?x=accept\" method=\"post\" enctype=\"multipart/form-data\">
<div>
<input type=\"file\" size=\"60\" name=\"filename\" />
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$limit\" />
<input type=\"submit\" value=\"upload\" />
</div>
</form>";
break;
case accept:
if (file_exists($file . $_FILES['filename']['name'])) {
print "Sorry, A file with this name already exists, please re-name the file and try again.<br /><br />[<a href=\"./\">back</a>]";
} else {
if ($_FILES['filename']['size'] >= $limit) {
print "File size too large<br /><br />[<a href=\"./\">back</a>]";
} else {
move_uploaded_file($_FILES['filename']['tmp_name'], $file . $_FILES['filename']['name']);
print "File Uploaded!, check [<a href=http://frankie.sytes.net/test/uploaded>all uploaded files here!</a>]!";
}
}
break;
}
?>
</div>
</body>
</html>
De fout zit geloof ik in "switch($_GET[x]) ". Ik weet alleen niet wat dit "switch"doet, en waarom het uberhaupt in het script staat, het simpel verwijderen van deze regel laat het script igg helemaal niet werken.
Ik hoop dat er iemand is die weet wat er mis is.
529 views