skeery2605 Posted September 26, 2014 Share Posted September 26, 2014 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 More sharing options...
Larry Posted September 26, 2014 Share Posted September 26, 2014 What version of PHP are you using? Link to comment Share on other sites More sharing options...
skeery2605 Posted September 27, 2014 Author Share Posted September 27, 2014 5.5.11 Link to comment Share on other sites More sharing options...
Larry Posted September 29, 2014 Share Posted September 29, 2014 Okay. That should be good. What operating system are you using? Link to comment Share on other sites More sharing options...
skeery2605 Posted September 29, 2014 Author Share Posted September 29, 2014 Windows 7 Professional 64bit Link to comment Share on other sites More sharing options...
skeery2605 Posted September 29, 2014 Author Share Posted September 29, 2014 I figured the problem i was having out.. i had to read the 13.3 again to see it. i had to enable the fileinfo.dll in the php.ini file. Everything works fine now. thanks for the help Link to comment Share on other sites More sharing options...
Larry Posted September 29, 2014 Share Posted September 29, 2014 Ah, excellent. Kudos for figuring it out and thanks for letting us know. Link to comment Share on other sites More sharing options...
Recommended Posts