[Vtigercrm-commits] [vtiger-commits] r10680 - /vtigercrm/branches/5.0.3/modules/uploads/add2db.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Fri Apr 13 07:35:23 EDT 2007


Author: richie
Date: Fri Apr 13 05:35:19 2007
New Revision: 10680

Log:
* Error handling has been done for error code 6 in file upload.

Modified:
    vtigercrm/branches/5.0.3/modules/uploads/add2db.php

Modified: vtigercrm/branches/5.0.3/modules/uploads/add2db.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/uploads/add2db.php (original)
+++ vtigercrm/branches/5.0.3/modules/uploads/add2db.php Fri Apr 13 05:35:19 2007
@@ -18,7 +18,7 @@
 $vtigerpath = str_replace("/index.php?module=uploads&action=add2db", "", $vtigerpath);
 
 $crmid = $_REQUEST['return_id'];
-$log->debug("DGDEBUG In add2db.php");
+$log->debug("DEBUG In add2db.php");
 
 	//fix for space in file name.
 	$_FILES['filename']['name'] = preg_replace('/\s+/', '_', $_FILES['filename']['name']);
@@ -61,30 +61,27 @@
 
 			# Added by DG 26 Oct 2005
 			# Attachments added to contacts are also added to their accounts
-			$log->debug("DGDEBUG Here's the test:");
-			$log->debug("DGDEBUG return_module: ".$_REQUEST['return_module']);
+			$log->debug("DEBUG return_module: ".$_REQUEST['return_module']);
 			if ($_REQUEST['return_module'] == 'Contacts')
 			{
-				$log->debug("DGDEBUG Passed the test.");
 				$crmid = $_REQUEST['return_id'];
 				$query = 'select accountid from vtiger_contactdetails where contactid='.$crmid;
-				$log->debug("DGDEBUG Running query: ".$query);
 				$result = $adb->query($query);
 				if($adb->num_rows($result) != 0)
 				{
-					$log->debug("DGDEBUG Returned a row");
+					$log->debug("DEBUG Returned a row");
 					$associated_account = $adb->query_result($result,0,"accountid");
 					# Now make sure that we haven't already got this attachment associated to this account
 					# Hmmm... if this works, should we NOT upload the attachment again, and just set the relation for the contact too?
-					$log->debug("DGDEBUG Associated Account: ".$associated_account);
+					$log->debug("DEBUG Associated Account: ".$associated_account);
 					$query = "select name,attachmentsize from vtiger_attachments where name= '".$filename."'";
 					$result = $adb->query($query);
 					if($adb->num_rows($result) != 0)
 					{
-						$log->debug("DGDEBUG Matched a row");
+						$log->debug("DEBUG Matched a row");
 						# Whoops! We matched the name. Is it the same size?
 						$dg_size = $adb->query_result($result,0,"attachmentsize");
-						$log->debug("DGDEBUG: These should be the same size: ".$dg_size." ".$filesize);
+						$log->debug("DEBUG: These should be the same size: ".$dg_size." ".$filesize);
 						if ($dg_size == $filesize)
 						{
 							# Yup, it is probably the same file
@@ -113,10 +110,9 @@
 			# Attachments added to contacts are also added to their accounts
 			if ($associated_account)
 			{
-				$log->debug("DGDEBUG: inserting into vtiger_seattachmentsrel from add2db 2");
+				$log->debug("DEBUG: inserting into vtiger_seattachmentsrel from add2db 2");
 				$sql1 = "insert into vtiger_seattachmentsrel values('";
 				$sql1 .= $associated_account."','".$current_id."')";
-				$log->debug("DGDEBUG: Here's the query: ".$sql1);
 				$result = $adb->query($sql1);
 			}
 
@@ -134,26 +130,30 @@
 	else 
 	{
 		$errorCode =  $_FILES['binFile']['error'];
+		$errormessage = "";
 
 		if($errorCode == 4)
 		{
 			$errormessage = "<B><font color='red'>Kindly give a valid file for upload!</font></B> <br>" ;
-			echo $errormessage;
-			include "upload.php";
 		}
 		else if($errorCode == 2)
 		{
-			$errormessage = "<B><font color='red'>Sorry, the uploaded file exceeds the maximum filesize limit. Please try a file smaller than 1000000 bytes</font></B> <br>";
-			echo $errormessage;
-			include "upload.php";
-			//echo $errorCode;
+			$errormessage = "<B><font color='red'>Sorry, the uploaded file exceeds the maximum filesize limit. Please try a file smaller than $upload_maxsize bytes</font></B> <br>";
+		}
+		else if($errorCode == 6)
+		{
+			$errormessage = "<B>Please configure <font color='red'>upload_tmp_dir</font> variable in php.ini file.</B> <br>" ;
 		}
 		else if($errorCode == 3 || $errorcode == '')
 		{
-			echo "<b><font color='red'>Problems in file upload. Please try again!</font></b><br>";
-			include "upload.php";
+			$errormessage = "<b><font color='red'>Problems in file upload. Please try again!</font></b><br>";
 		}
 
+		if($errormessage != '')
+		{
+			echo $errormessage;
+			include("upload.php");
+		}
 	}
 
 ?>





More information about the vtigercrm-commits mailing list