[Klug-general] PHP Uploads

Karl Lattimer karl at nncc.info
Tue Feb 15 17:18:40 GMT 2005


Here you go;

HTML form

<form action="fileupload.php" "enctype multipart/form-data"
method="POST>
  <input type="hidden" name="MAX_FILE_SIZE" value="512000">
  <input type="file" name="fileupload"><input type="submit"
value="upload!">
</form>

PHP handler

$file_dir = "/path/to/upload";

foreach ($_FILES as $file_name => $file_array) {
	if (is_uploaded_file($file_array['tmp_name'])) {
		move_uploaded_file($file_array['tmp_name'],
		"$file_dir/$file_array[name] or die ("Cannot copy");
	}
}

Thats how it _should_ be done by all accounts, and that is the method I
use.

Karl,




More information about the Kent mailing list