Jump to content

[SOLVED] File Upload not uploading


DarkPrince2005

Recommended Posts

I have a script that uploads a file to a database, but it won't upload any file bidder than 1 meg. Why could this be?

 

Add

<html>
<head>
<title>Case Management: Upload</title>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<style>

	a:link{font-family:'Verdana';

	color:'#000000';
	font-weight:700;
	text-decoration:none;
	}

	a:visited{font-family:'Verdana';

	color:'#000000';
	font-weight:700;
	text-decoration:None;
	}

	a:hover{font-family:'Verdana';

	text-decoration:none;
	color:'#B37A04';
	font-weight:700;
	}

	a:active{font-family:'Verdana';

	color:'#000000';
	font-weight:700;
	}
</style>

</head>
<body background="graphics/back.gif" topmargin='0' bottommargin='0' leftmargin='0' rightmargin='0'>
<center><table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td valign='top' width="140" background="graphics/nav.gif"><br><center><font size=3>MENU</font><br><img src='graphics/NavSeparator.gif' width=130></center><br>
	<font size="2"><a href="">  <img src="graphics/NavBullet.gif" border=0>  Home</a></font><br><br>
	<font size="2"><a href="download.php">  <img src="graphics/NavBullet.gif" border=0>  View Cases</a></font><br><br>
	<font size="2"><a href="add.html">  <img src="graphics/NavBullet.gif" border=0>  Add Cases</a></font><br><br>
	<font size="2"><a href="">  <img src="graphics/NavBullet.gif" border=0>  Edit Cases</a></font><br><br>
	<font size="2"><a href="">  <img src="graphics/NavBullet.gif" border=0>  Delete Cases</a></font><br><br>
	<font size="2"><a href="">  <img src="graphics/NavBullet.gif" border=0>  Case Report</a></font><br><br>
	<font size="2"><a href="">  <img src="graphics/NavBullet.gif" border=0>  Query Report</a></font><br><br>
	<font size="2"><a href="">  <img src="graphics/NavBullet.gif" border=0>  Search</a></font><br><br><br><center><img src='graphics/NavSeparator.gif' width=130></center><br></td><td valign="top" align="center"><table><tr>
	<td align="right" valign="top">  </td></tr>
	<td align="center" valign="top"><h1><u>Add Case</u></h1></td></tr>
<tr><td align="center" valign="top"> </td></tr>
<tr><td align="center" valign="top"><br><form method="post" action='upload.php' enctype="multipart/form-data">
<center>

<table width="600" cellpadding="0" cellspacing="0">
<tr>
	<td>
		<table>
			<tr>
				<td><b>Capture Date:</td>
				<td> </td>
				<td><input type="text" name="date"></td>
			</tr>
			<tr>
				<td><b>Applicant:</td>
				<td> </td>
				<td><input type="text" name="applicant"></td>
			</tr>
			<tr>
				<td><b>Respondent</td>
				<td> </td>
				<td><input type="text" name="respondent"></td>
			</tr>
			<tr>
				<td><b>Case Number:</td>
				<td> </td>
				<td><input type="text" name="case_number"></td>
			</tr>
			<tr>
				<td><b>Judge:</td>
				<td> </td>
				<td><input type="text" name="judge"></td>
			</tr>
			<tr>
				<td><b>Representative:</td>
				<td> </td>
				<td><input type="text"  name="representative"></td>
			</tr>
		</table>
	</td>
	<td valign="top">
		<table>
			<tr>
				<td><b>Offence/Charge:</td>
				<td> </td>
				<td><input type="text" name="offence"></td>
			</tr>
			<tr>
				<td><b>Outcome</td>
				<td> </td>
				<td><input type="text" name="outcome"></td>
			</tr>
			<tr>
				<td><b>Relief:</td>
				<td> </td>
				<td><input type="text" name="relief"></td>
			</tr>
			<tr>
				<td><b>Occupation:</td>
				<td> </td>
				<td><input type="text" name="occupation"></td>
			</tr>
			<tr>
				<td><b>Region</td>
				<td> </td>
				<td><input type="text" name="region"></td>
			</tr>
			<tr>
				<td><b>Status</td>
				<td> </td>
				<td><input type="text" name="status"></td>
			</tr>
		</table>
	</td>
</tr>
<tr>
	<td colspan="2">
		<table width="600">
			<tr>
				<td colspan=2><b>Case Summary:</td>
			</tr>
			<tr>
				<td> </td>
				<td><textarea cols="58" rows="10" name="case_summary"></textarea></td>
			</tr>
			<tr>
				<td align="center"> </td>
			</tr>
			<tr>
				<td><strong>File Upload:</strong></td>
			</tr>
			<tr>
				<td> </td>
				<td>
				<input type="hidden" name="MAX_FILE_SIZE" value="5000000">
				<input name="userfile" type="file" id="userfile" size="50"> 
				</td>
			</tr>
			<tr>
				<td align="center"> </td>
			</tr>
			<tr>
				<td colspan="2" align="center"><input name="upload" type="submit" class="box" id="upload" value=" Upload "></td>
			</tr>
		</table>
	</td>
</tr>
</table>
</form></td></tr></table>
</body>

 

Upload

<?php

ini_set('display_errors','On');
error_reporting(E_ALL);

ini_set('upload_max_filesize','5M');

ini_set('max_execution_time','180');

ini_set('max_input_time','180');

mysql_connect("localhost","root","");

  mysql_select_db("npa");
  
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];

$fp      = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);

if(!get_magic_quotes_gpc())
{
    $fileName = addslashes($fileName);
}


$query = mysql_query("INSERT INTO case_management (date, applicant, respondent, case_number, judge, representative, offence, outcome, relief, occupation, region, status, case_summary, name, size, type, content ) ".
"VALUES ('$_POST[date]','$_POST[applicant]','$_POST[respondent]','$_POST[case_number]','$_POST[judge]','$_POST[representative]','$_POST[offence]','$_POST[outcome]','$_POST[relief]','$_POST[occupation]','$_POST[region]','$_POST[status]',\"$_POST[case_summary]\",'$fileName', '$fileSize', '$fileType', '$content')");


//mysql_query($query) or die('Error, query failed'); 
echo "<script language=JavaScript>window.location='add.html'</script>";
}
else
{
$sql = mysql_query("INSERT INTO case_management (date, applicant, respondent, case_number, judge, representative, offence, outcome, relief, occupation, region, status, case_summary, name, size, type, content ) VALUES ('$_POST[date]','$_POST[applicant]','$_POST[respondent]','$_POST[case_number]','$_POST[judge]','$_POST[representative]','$_POST[offence]','$_POST[outcome]','$_POST[relief]','$_POST[occupation]','$_POST[region]','$_POST[status]',\"$_POST[case_summary]\",'', '', '', '','')");

echo "<script language=JavaScript>window.location='add.html'</script>";
};
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.