ok i have a problem and it does not seem to be the php.ini problem.

what would cause my upload script for files to not completely execute and then just show me a blank page. not file uploaded and no record to the DB.

i am giving the upload code to see if there is a problem in it.

$id = $_GET['id'];
$file = $_FILES['document']['name'];
$docname = $_POST['docname'];

if ($file == '') {
	echo 'Please select a document to upload.';
	echo '<br /><a href="javascript:history.go(-1);">&lt;&lt Go Back</a>';
	exit;
}
if ($docname == '') {
	echo 'Please insert a document name so that you know what it is.';
	echo '<br /><a href="javascript:history.go(-1);">&lt;&lt Go Back</a>';
	exit;
}


			  $filename = $file;
			  $filename=str_replace(" ","_",$filename);// Add _ inplace of blank space in file name, you can remove this line
			  $ext = substr(strrchr($filename, "."), 1);
			  
			  $allowedExtensions = array("doc","xls","ppt","pdf"); 
			  if (!in_array($ext, $allowedExtensions)) {
				  echo "File type not allowed";
				  echo '<br /><a href="javascript:history.go(-1);">&lt;&lt Go Back</a>';
				  exit;
				  }
			  
			  $randName = md5(rand() * time());
			  $filename = $randName . '.' . $ext;;
			  $source = $_FILES['document']['tmp_name'];
			  $target = "documents/".$filename;

					$add = "documents/$filename";
                       //echo $_FILES['images']['type'][$key];
			     // echo "<br>";
					copy($_FILES['document']['tmp_name'], $add);
					chmod("$add",0777);
						
			$query = "INSERT INTO paperwork (file, name, company_id, file_id)
											   VALUES ('$filename', '$docname', '$company_id', '$id')";

			$result = mysql_query($query);			
			if ($result) {
	$message = 'Yay the query was successfully run555.';
}
else{
	$message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: <em>' . $query . '</em>';
    die($message);
}



echo '<h3>The File Was Uploaded Successfully</h3>';
echo '<code><script language=javascript>setTimeout(\'parent.tb_remove(); parent.location.reload(1)\', 1500);</script></code>';

thanks in advanced

do you have display_errors set to On?

yes it is set to on.

Are you trying to upload files bigger than the size limit in php.ini? if the script works with small size file then the script is fine and the error is in php.ini.

Another issue may be that your server has some strict security. Sometimes mod_security doesn't like a part of the url. If you have mod_security check the logs.

If indeed you are uploading big files but your settings are ok with this check that the script is not timing out. Use set_time_limit(0); at the beginning of the script.

thanks for the reply. i dont understand what the problem is. i did upload a smaller file. and i did add that set_time thing and still have that issue. i am soo stumped. and it is getting annoying

can you add the code of the form itself, please?

case "paperwork":
        echo '
		<div style="border:dashed 1px #000000;">
		  <form action="add.php?id='.$id.'" method="post" enctype="multipart/form-data" >
  <div class="blue" style="text-align:left">
  <input name="addpaperwork" type="submit" value="Add&nbsp;Paperwork" class="btn" />
  or <a href="#" onclick="parent.tb_remove();">cancel</a><br />
 </div> 
 <table cellpadding="5">
  <tr>
    <td>Document:</td>
    <td><input type="file" name="document"/></td>
  </tr>
  <tr>
    <td>Document Name:</td>
    <td><input name="docname" type="text" /></td>
  </tr>
</table>
  </form>
  </div><br /> 
		';

i have reuploaded a new php.ini and changed just the memory limit and the max file size. and i still get a blank page in the middle of the upload. it is really weird cause it used to work but i dont know why it just started to act up.

i even added a couple of echos to it and i didnt even get those

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.