A code is failing to upload a scanned file/document, then saving in the database and then giving an option for retrieving the saved file.
CODE
<html>
<head>
<title>A simple file upload form</title>
</head>
<body>
<form action="do_upload.php" enctype="multipart/form-data" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="51200">
<p><strong>File to Upload:</strong> <input type="file" name="fileupload"></p>
<p><input type="submit" value="upload!"></p>
</form>
</body>
</html>
<?php
$file_dir = "";
foreach($_FILES as $file_name => $file_array) {
echo "path: ".$file_array['tmp_name']."<br>\n";
echo "name: ".$file_array['name']."<br>\n";
echo "type: ".$file_array['type']."<br>\n";
echo "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");
echo "file was moved!<br><br>";
}
}
?>