Hej
Hvis du får fat i bogen på denne side:
http://www.libris.dk/Vis_produkt.asp?ISBN=87-7843-617-6
er den en udemærket beskrivelse side 176.
formular:
<html>
<head>
<title>Listing 9.13 A simple file upload form</title>
</head>
<body>
<form action="listing9.14.php" enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="51200">
File to Upload: <input type="file" name="fileupload"><br><br>
<input type="submit" value="upload!">
</form>
</body>
</html>
script til håndtering:
<html>
<head>
<title>Listing 9.14 A file upload script</title>
</head>
<body>
<h1>File Upload Results</h1>
<?php
$file_dir = "/path/to/upload/directory";
foreach($_FILES as $file_name => $file_array) {
print "path: ".$file_array['tmp_name']."<br>\n";
print "name: ".$file_array['name']."<br>\n";
print "type: ".$file_array['type']."<br>\n";
print "size: ".$file_array['size']."<br>\n";
if (is_uploaded_file($file_array['tmp_name'])) {
move_uploaded_file($file_array['tmp_name'], "$file_dir/$file_array[name]") or die ("Couldn't copy");
print "file was moved!<br><br>";
}
}
?>
</html>