diff --git a/modules/Documents/models/Record.php b/modules/Documents/models/Record.php
index 44cd7b29e373f549c1f61e9891b69d663cc266fe..c87e720781ac0bcc00de464490d6bc9df566fbae 100644
--- a/modules/Documents/models/Record.php
+++ b/modules/Documents/models/Record.php
@@ -77,24 +77,29 @@ class Documents_Record_Model extends Vtiger_Record_Model {
 
 			if ($this->get('filelocationtype') == 'I') {
 				$fileName = html_entity_decode($fileName, ENT_QUOTES, vglobal('default_charset'));
-				$savedFile = $fileDetails['attachmentsid']."_".$storedFileName;
-
-				while(ob_get_level()) {
-					ob_end_clean();
-				}
-				$fileSize = filesize($filePath.$savedFile);
-				$fileSize = $fileSize + ($fileSize % 1024);
-
-				if (fopen($filePath.$savedFile, "r")) {
-					$fileContent = fread(fopen($filePath.$savedFile, "r"), $fileSize);
-
-					header("Content-type: ".$fileDetails['type']);
-					header("Pragma: public");
-					header("Cache-Control: private");
-					header("Content-Disposition: attachment; filename=\"$fileName\"");
-					header("Content-Description: PHP Generated Data");
-                    header("Content-Encoding: none");
-				}
+                if (!empty($fileName)) {
+                    if(!empty($storedFileName)){
+                        $savedFile = $fileDetails['attachmentsid']."_".$storedFileName;
+                    }else if(is_null($storedFileName)){
+                        $savedFile = $fileDetails['attachmentsid']."_".$fileName;
+                    }
+                    while(ob_get_level()) {
+                        ob_end_clean();
+                    }
+                    $fileSize = filesize($filePath.$savedFile);
+                    $fileSize = $fileSize + ($fileSize % 1024);
+
+                    if (fopen($filePath.$savedFile, "r")) {
+                        $fileContent = fread(fopen($filePath.$savedFile, "r"), $fileSize);
+
+                        header("Content-type: ".$fileDetails['type']);
+                        header("Pragma: public");
+                        header("Cache-Control: private");
+                        header("Content-Disposition: attachment; filename=\"$fileName\"");
+                        header("Content-Description: PHP Generated Data");
+                        header("Content-Encoding: none");
+                    }
+                }
 			}
 		}
 		echo $fileContent;
diff --git a/modules/Emails/actions/DownloadFile.php b/modules/Emails/actions/DownloadFile.php
index 882a1ddf51926287e7d310f67133f82b6577bf0b..60b2ae498f79115b89564f5189d817fdc9662840 100644
--- a/modules/Emails/actions/DownloadFile.php
+++ b/modules/Emails/actions/DownloadFile.php
@@ -21,34 +21,40 @@ class Emails_DownloadFile_Action extends Vtiger_Action_Controller {
 	}
 
 	public function process(Vtiger_Request $request) {
-        $db = PearDatabase::getInstance();
+       $db = PearDatabase::getInstance();
 
-        $attachmentId = $request->get('attachment_id');
-        $name = $request->get('name');
-        $query = "SELECT * FROM vtiger_attachments WHERE attachmentsid = ? AND name = ?" ;
-        $result = $db->pquery($query, array($attachmentId, $name));
+       $attachmentId = $request->get('attachment_id');
+       $name = $request->get('name');
+       $query = "SELECT * FROM vtiger_attachments WHERE attachmentsid = ? AND name = ?" ;
+       $result = $db->pquery($query, array($attachmentId, $name));
 
-        if($db->num_rows($result) == 1)
-        {
-            $row = $db->fetchByAssoc($result, 0);
-            $fileType = $row["type"];
-            $name = $row["name"];
-            $filepath = $row["path"];
-            $name = decode_html($name);
-            $storedFileName = $row['storedname'];
-            $saved_filename = $attachmentId."_". $storedFileName;
-            $disk_file_size = filesize($filepath.$saved_filename);
-            $filesize = $disk_file_size + ($disk_file_size % 1024);
-            $fileContent = fread(fopen($filepath.$saved_filename, "r"), $filesize);
+       if($db->num_rows($result) == 1)
+       {
+           $row = $db->fetchByAssoc($result, 0);
+           $fileType = $row["type"];
+           $name = $row["name"];
+           $filepath = $row["path"];
+           $name = decode_html($name);
+           $storedFileName = $row['storedname'];
+           if (!empty($name)) {
+               if(!empty($storedFileName)){
+                   $saved_filename = $attachmentId."_". $storedFileName;
+               }else if(is_null($storedFileName)){
+                   $saved_filename = $attachmentId."_". $name;
+               }
+               $disk_file_size = filesize($filepath.$saved_filename);
+               $filesize = $disk_file_size + ($disk_file_size % 1024);
+               $fileContent = fread(fopen($filepath.$saved_filename, "r"), $filesize);
 
-            header("Content-type: $fileType");
-            header("Pragma: public");
-            header("Cache-Control: private");
-            header("Content-Disposition: attachment; filename=$name");
-            header("Content-Description: PHP Generated Data");
-            echo $fileContent;
-        }
-    }
+               header("Content-type: $fileType");
+               header("Pragma: public");
+               header("Cache-Control: private");
+               header("Content-Disposition: attachment; filename=$name");
+               header("Content-Description: PHP Generated Data");
+               echo $fileContent;
+           }
+       }
+   }
 }
 
 ?>
diff --git a/modules/Migration/models/Module.php b/modules/Migration/models/Module.php
index 2cd96cc4055b061624f709d6d4e2810773de370f..44cef6173231d910b14f6ff0da11d83cae193031 100644
--- a/modules/Migration/models/Module.php
+++ b/modules/Migration/models/Module.php
@@ -39,6 +39,8 @@ class Migration_Module_Model extends Vtiger_Module_Model {
 			array('700' => '7.0.0'),
 			array('701' => '7.0.1'),
 			array('710' => '7.1.0'),
+            array('711' => '7.1.1'),
+            array('720' => '7.2.0'),
 		);
 		return $versions;
 	}
diff --git a/modules/Migration/schema/711_to_720.php b/modules/Migration/schema/711_to_720.php
index fa7be894350a8f5086a0cd9b59d7acfab11fafde..abf2134192ac5e4cda3f6e6cb73b21587bae49ca 100644
--- a/modules/Migration/schema/711_to_720.php
+++ b/modules/Migration/schema/711_to_720.php
@@ -13,5 +13,5 @@ if (defined('VTIGER_UPGRADE')) {
 	$db = PearDatabase::getInstance();
 
 	// Added column storedname for vtiger_attachments to support reverse mapping.
-	$db->pquery('ALTER TABLE vtiger_attachments ADD COLUMN storedname varchar(255) NOT NULL AFTER path', array());
+	$db->pquery('ALTER TABLE vtiger_attachments ADD COLUMN storedname varchar(255) NULL AFTER path', array());
 }
diff --git a/modules/Vtiger/helpers/ShowFile.php b/modules/Vtiger/helpers/ShowFile.php
index 8baa67c7a30e77c4ca1a0d63155479b377856249..ac466f5fea62e537b798f7ecd16323f81e4e87f0 100644
--- a/modules/Vtiger/helpers/ShowFile.php
+++ b/modules/Vtiger/helpers/ShowFile.php
@@ -1,12 +1,12 @@
 <?php
-/*+***********************************************************************************
+/* +***********************************************************************************
  * The contents of this file are subject to the vtiger CRM Public License Version 1.0
  * ("License"); You may not use this file except in compliance with the License
  * The Original Code is:  vtiger CRM Open Source
  * The Initial Developer of the Original Code is vtiger.
  * Portions created by vtiger are Copyright (C) vtiger.
  * All Rights Reserved.
- *************************************************************************************/
+ * *********************************************************************************** */
 
 class Vtiger_ShowFile_Helper {
 
@@ -16,39 +16,43 @@ class Vtiger_ShowFile_Helper {
 	 * @param type $encFileName - md5(filename)
 	 */
 	static function handle($fid, $encFileName) {
-        global $upload_badext;
+		global $upload_badext;
 		$db = PearDatabase::getInstance();
 
 		$query = "SELECT vtiger_attachments.* FROM vtiger_attachments
-					INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_attachments.attachmentsid
-					WHERE vtiger_attachments.attachmentsid=? AND vtiger_attachments.name=? LIMIT 1";
+INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_attachments.attachmentsid
+WHERE vtiger_attachments.attachmentsid=? AND vtiger_attachments.name=? LIMIT 1";
 		$result = $db->pquery($query, array($fid, $encFileName));
 		if ($result && $db->num_rows($result)) {
-			$resultData	= $db->fetch_array($result);
-			$fileId		= $resultData['attachmentsid'];
-			$filePath	= $resultData['path'];
-			$fileName	= $resultData['name'];
-            $storedFileName = $resultData['storedname'];
-			$fileType	= $resultData['type'];
+			$resultData = $db->fetch_array($result);
+			$fileId = $resultData['attachmentsid'];
+			$filePath = $resultData['path'];
+			$fileName = $resultData['name'];
+			$storedFileName = $resultData['storedname'];
+			$fileType = $resultData['type'];
 			$sanitizedFileName = sanitizeUploadFileName($fileName, $upload_badext);
 
 			/**
 			 * While saving the document applying decode_html to save in DB, but this is not happening for the images
 			 * This save happens from mailroom, inbox, record save, document save etc..
 			 */
-			if (!empty($encFileName) && !empty($storedFileName)) {
-				$finalFilePath = $filePath.$fileId.'_'.$storedFileName;
+			if (!empty($encFileName)) {
+				if (!empty($storedFileName)) {
+					$finalFilePath = $filePath . $fileId . '_' . $storedFileName;
+				} else if (is_null($storedFileName)) {
+					$finalFilePath = $filePath . $fileId . '_' . $encFileName;
+				}
 				$isFileExist = false;
 				if (file_exists($finalFilePath)) {
 					$isFileExist = true;
 				} else {
-					$finalFilePath = $filePath.$fileId.'_'.$sanitizedFileName;
+					$finalFilePath = $filePath . $fileId . '_' . $sanitizedFileName;
 					if (file_exists($finalFilePath)) {
 						$isFileExist = true;
 					}
 				}
 				if ($isFileExist) {
-					Vtiger_ShowFile_Helper::show($finalFilePath,$fileType);
+					Vtiger_ShowFile_Helper::show($finalFilePath, $fileType);
 				}
 			}
 		}
@@ -67,4 +71,4 @@ class Vtiger_ShowFile_Helper {
 		header("Content-Type: $fileType;charset=UTF-8");
 		echo $contents;
 	}
-}
\ No newline at end of file
+}
diff --git a/modules/Vtiger/models/Record.php b/modules/Vtiger/models/Record.php
index 00e4b3198e34a12bcc167fe649196b676bf2c2b7..c6d9a683f1242d36afbde66365623087ea41629d 100644
--- a/modules/Vtiger/models/Record.php
+++ b/modules/Vtiger/models/Record.php
@@ -593,18 +593,24 @@ class Vtiger_Record_Model extends Vtiger_Base_Model {
 			$fileName = $fileDetails['name'];
             $storedFileName = $fileDetails['storedname'];
 			$fileName = html_entity_decode($fileName, ENT_QUOTES, vglobal('default_charset'));
-			$savedFile = $fileDetails['attachmentsid']."_".$storedFileName;
-			$fileSize = filesize($filePath.$savedFile);
-			$fileSize = $fileSize + ($fileSize % 1024);
-			if (fopen($filePath.$savedFile, "r")) {
-				$fileContent = fread(fopen($filePath.$savedFile, "r"), $fileSize);
-				header("Content-type: ".$fileDetails['type']);
-				header("Pragma: public");
-				header("Cache-Control: private");
-				header("Content-Disposition: attachment; filename=\"$fileName\"");
-				header("Content-Description: PHP Generated Data");
-				header("Content-Encoding: none");
-			}
+            if (!empty($fileName)) {
+                if(!empty($storedFileName)){
+                    $savedFile = $fileDetails['attachmentsid']."_".$storedFileName;
+                }else if(is_null($storedFileName)){
+                    $savedFile = $fileDetails['attachmentsid']."_".$fileName;
+                }
+                $fileSize = filesize($filePath.$savedFile);
+                $fileSize = $fileSize + ($fileSize % 1024);
+                if (fopen($filePath.$savedFile, "r")) {
+                    $fileContent = fread(fopen($filePath.$savedFile, "r"), $fileSize);
+                    header("Content-type: ".$fileDetails['type']);
+                    header("Pragma: public");
+                    header("Cache-Control: private");
+                    header("Content-Disposition: attachment; filename=\"$fileName\"");
+                    header("Content-Description: PHP Generated Data");
+                    header("Content-Encoding: none");
+                }
+            }
 		}
 		echo $fileContent;
 	}
diff --git a/schema/DatabaseSchema.xml b/schema/DatabaseSchema.xml
index 68d7d560e0594184c49676ffdc546d81fb4693d8..bc7399e40bbc004148d11b1b665473ff63de33c0 100644
--- a/schema/DatabaseSchema.xml
+++ b/schema/DatabaseSchema.xml
@@ -1014,6 +1014,7 @@
 		<field name="description" type="X" />
 		<field name="type" type="C" size="100" />
 		<field name="path" type="X" />
+                <field name="storedname" type="C" size="255" />
 		<field name="subject" type="C" size="255" />
 		<index name="attachments_attachmentsid_idx">
 			<col>attachmentsid</col>
diff --git a/vtigerversion.php b/vtigerversion.php
index 47cdbef270e0ec732b927ab8e50d1a994d587378..f52201a7ee0d51ef42c1951bce09f6757b97dae8 100644
--- a/vtigerversion.php
+++ b/vtigerversion.php
@@ -8,9 +8,9 @@
  * All Rights Reserved.
  ************************************************************************************/
 
-$patch_version = '20180308'; // -ve timestamp before release, +ve timestamp after release.
+$patch_version = '-20190904'; // -ve timestamp before release, +ve timestamp after release.
 $modified_database = '';
-$vtiger_current_version = '7.1.1';
+$vtiger_current_version = '7.2.0';
 $_SESSION['vtiger_version'] = $vtiger_current_version;
 
 ?>