Hey all,
This problem just came up in my website and I'm having a hard time figuring out what's wrong. I have a intranet portal running (custom built) and I'm storing all different types of documents in a mysql database. Previously, I was able to read the contents of the file into the DB and then pull it out and the file would open just fine. Now, for some reason, everything except PDF files come across as gibberish.
I've gone ahead and tried to upload files that I know are working, I've switched from base64_encode to addslashes, tried to do a mysql COMPRESS and UNCOMPRESS when uploading a new file....nothing. I'm just not sure why all of a sudden this stopped functioning properly (haven't done any upgrades to the server, db or code)
Anyone have any ideas I can try?
For reference, the code for inserting and downloading follows:
insert:
case "Add File":
$fp = fopen($_FILES['userfile']['tmp_name'], 'r');
$content = fread($fp, filesize($_FILES['userfile']['tmp_name']));
$content = base64_encode($content);
mysql_query("INSERT INTO intranet.documents(id, type, contents, content, name, category, updated) VALUES ('', '".$_FILES['userfile']['type']."', '".$content."', COMPRESS('".$content."'), '".addslashes(str_replace(" ", "_", strtolower($_FILES['userfile']['name'])))."','".$_POST['category']."', '".date("Y-m-d H:i:s")."')") or die(mysql_error());
fclose($fp);
redirect("?action=".$_GET['action']);
break;
download:
$_SESSION['content'] = NULL;
$result = mysql_query("SELECT name, type, contents FROM intranet.documents WHERE ID = '".$_GET['id']."'") or die(mysql_error());
$_SESSION['content'] = base64_decode(mysql_result($result, 0, "contents"));
header("Content-Disposition: attachment; filename=".mysql_result($result, 0, "name")."");
header("Content-type: ".mysql_result($result, 0, "type"));
Mail from PHP form not always ending up in my inbox?
Hi guys,I'm a real newbie to PHP and have managed to put together a simple mail form that sends me an email when someone fills it in on my site.The problem I am having, is that sometimes when I test
Track downloads' status
Hello,I need to make somehow, some system, to track whether downloads are completed or failed. I tried to make this via php.Tried to limit the connection speed for smaller downloads (to have the time
using variables in another page
I have a test database set up on localhost. I have a form that I can type a name into, hit the button and it puts the name into the database and into a list on my page. it works fine. Now, I wanted to
Unable to display contents in Second Drop Down Box
Hi All, What I am trying to do is 2 dependent drop down boxes and when user selects submit button the values are to be passed to the database to run a insert query. Right now, I am stuck
Checking if field is empty AND using !is_numeric
Hi lads,Need to be able to display an error message (using isset?) that says "Cant leave field blank" when someone clicks on submit after leaving the field blank. The problem is that I'm
add text and number image
hi guys ..ok see i want the user to add their name and pick a number then click get it and it prints the name on top and the number bellow it on a t-shirt i just cant seem to get this rite i have no
Parse error: syntax error, unexpected T_ELSEIF in /home/......html/item.php on l
I do not know what is wrong with this. Hope some one can help. I do nto want to post the entire site because it is to long. However, here is the few lines:$TPL_closed_auctions_list .=
str_replace help
Hey there,I'm a PHP newb, I'm having troubles with the str_replace function. I want to clean up bad html to valid xhtml, I am using:Code: $pee = str_replace('&', '&', $pee);It
C++ API to Oracle dB
I need to perform a select command to the Oracle dB to obtain information from a table.What libraries can I link into my project to make this work?I read about the OCI - but I cannot find any
shift numbers with paging
HiHow would i be able to display 10 numbers 1 2 3 4 5 6 7 8 9 10 and when I click next then 2 3 4 5 6 7 8 9 10 11 and click next then 3 4 5 6 7 8 9 10 11 12are displayed.i am using a for loop to echo