Jump to content
Larry Ullman's Book Forums

Recommended Posts

I cant get the uploader to work. I get the same error with my file or the downloadable file.

 

 

 

Fatal error: Call to undefined function finfo_open() in C:\xampp\htdocs\lessons\chapter_13\upload_rtf.php on line 17

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upload a RTF Document</title>
</head>
<body>
<?php # Script 13.3 upload_rtf.php


if ($_SERVER['REQUEST_METHOD'] == 'POST') {
	

if (isset($_FILES['upload']) && file_exists($_FILES['upload']['tmp_name'])) {
	
	
$fileinfo = finfo_open(FILEINFO_MIME_TYPE);


if (finfo_file($fileinfo, $_FILES['upload']['tmp_name']) == 'text/rtf') {
	echo '<p><em>The file would be acceptable!</em></p>';
	
	
unlink($_FILES['upload']['tmp_name']);


} else { // invalid type
	echo '<p style="font-weight: bold; color: #C00">Please upload an RTF Document.</p>';
	
}

finfo_close($fileinfo);

}

}
?>

<form enctype="multipart/form-data" action="upload_rtf.php" method="post"><input type="hidden" name="MAX_FILE_SIZE" value="524288" />
	<fieldset>
		<legend>Select an RTF document of 512KB or smaller to be uploaded:</legend>
			<p><b>File:</b><input type="file" name="upload" /></p>
	</fieldset>
		<div align="center"><input type="submit" name="submit" value="Submit" /></div>
</form>
</body>
</html>
Link to comment
Share on other sites

 Share

×
×
  • Create New...