aethelwulffe wrote on Friday, December 10, 2010:
I really think this should be in the “Help” forum, so if a moderator finds this, sorry, I’m just a thread hijacker/necroposter/jerk, and I apologize for adding to this.
I, being volunteer admin for a non-prof mental health agency myself, need this very same thing. I found TWO contributed forms in the directory. One named “scanned_notes” which was broken and could not make the directory it needed, and another called “documents” “documents” works, and even has some crude install notes written in Pigeon English (also called “IT_Guy_Phonics”). “documents” include, as I said, works, but I was also not able to upload a .png, or .pdf.
I noticed it does an extension check like this:
if (($HTTP_POST_FILES['document_image']['type'] == 'image/gif') ||
($HTTP_POST_FILES['document_image']['type'] == 'image/jpg') ||
($HTTP_POST_FILES['document_image']['type'] == 'image/pjpeg') ||
($HTTP_POST_FILES['document_image']['type'] == 'image/jpeg') ||
($HTTP_POST_FILES['document_image']['type'] == 'image/bmp')){
$checktype='ok';
}
I tried inserting the following:
($HTTP_POST_FILES['document_image']['type'] == 'image/pdf') ||
But that changed nothing at all. No difference in the behavior when I uploaded.
I am a php N00B.
I imagine that image/ would have a specific use here, as it is obviously NOT a path. I bet another format would be ‘text/txt’ etc…
I found some code that looked helpful.
<?php
// begin Dave B's Q&D file upload security code
$allowedExtensions = array("txt","csv","htm","html","xml",
"css","doc","xls","rtf","ppt","pdf","swf","flv","avi",
"wmv","mov","jpg","jpeg","gif","png");
foreach ($_FILES as $file) {
if ($file['tmp_name'] > '') {
if (!in_array(end(explode(".",
strtolower($file['name']))),
$allowedExtensions)) {
die($file['name'].' is an invalid file type!<br/>'.
'<a href="javascript:history.go(-1);">'.
'<< Go Back</a>');
}
}
}
// end Dave B's Q&D file upload security code
?>
I also found out that $_FILES depreciated $HTTP_POST_FILES, and I havn’e located and API or manual that explains more about this php “array” (which really doesn’t seem to be an array at all to me, further confusing me).
Next issue that we will probably have is that to display a pdf, we are going to have to show it as a frame with an href in it, or something like that (I ain’t that great in HTML either…not a web dev type …yet…)
This code stores the file in a directory, not an sql blob, right? We should just be able to add some (ok, quite a bit of) code in here and get this form doing an html frame displaying adobe reader, html, .odt etc, right?
I thought looking for the interface for the regular patient’s documents would help as an example, but I havn’t been able to find the files/includes responsible for that behavior. The source of the frame points me to “controller.php” but that isn’t really it. There is just so much extraneous and supplanted stuff (freeB, broken style sheets, broken contribs, sql ledger etc…) in the code it is hard to track things down for an idiot noob. Anyone got any pointers for me/us?