bobrivers2003
Technical User
I have a html form that allows files to be uploaded to a mysql server, max file size 2mb. I have a page that lists all the files as links and when clicked allows the files to be saved or opened.
It works a treat with all types of files and validates if over 2 mb.
However if I try to upload a zip file and then attempt to open it the archive is not recognised.
This is the form:
<td width=\"246\">Attachment- 2Mb Limit: (Click Browse) <br><input type=\"hidden\" name=\"MAXFILESIZE\" value=\"2000000\"><input name=\"userfile\" type=\"file\" class=\"box\" id=\"userfile\">
This is the php that stores it to the db:
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
if(!($fileName==null))
{
$fp = fopen($tmpName, 'r');
$content = fread($fp, $fileSize);
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$query = "INSERT INTO table (username, date, time, query, p_level, a_name, state, feedback, filename, size, type, content ) VALUES('$cookieuname', '$currdate', '$currtime', '$query', '0', '$assignedTo', '$stateVar', '$feedbackVar', '$fileName', '$fileSize', '$fileType', '$content')";
mysql_query($query) or die('<b>Error, query failed</b>');
Can anyone tell me why zip files won't work?
It works a treat with all types of files and validates if over 2 mb.
However if I try to upload a zip file and then attempt to open it the archive is not recognised.
This is the form:
<td width=\"246\">Attachment- 2Mb Limit: (Click Browse) <br><input type=\"hidden\" name=\"MAXFILESIZE\" value=\"2000000\"><input name=\"userfile\" type=\"file\" class=\"box\" id=\"userfile\">
This is the php that stores it to the db:
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
if(!($fileName==null))
{
$fp = fopen($tmpName, 'r');
$content = fread($fp, $fileSize);
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}
$query = "INSERT INTO table (username, date, time, query, p_level, a_name, state, feedback, filename, size, type, content ) VALUES('$cookieuname', '$currdate', '$currtime', '$query', '0', '$assignedTo', '$stateVar', '$feedbackVar', '$fileName', '$fileSize', '$fileType', '$content')";
mysql_query($query) or die('<b>Error, query failed</b>');
Can anyone tell me why zip files won't work?