Commit 051db385c2138247f357f0aebbe240f8e9c66d5b

Authored by michael
1 parent ddd9d1d1

(#2838) added check for zero sized uploaded document


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2545 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentBL.php
@@ -37,8 +37,9 @@ if (checkSession()) { @@ -37,8 +37,9 @@ if (checkSession()) {
37 if (isset($fStore)) { 37 if (isset($fStore)) {
38 // check that a document type has been selected 38 // check that a document type has been selected
39 if ($fDocumentTypeID) { 39 if ($fDocumentTypeID) {
40 - //make sure the user actually selected a file first  
41 - if (strlen($_FILES['fFile']['name']) > 0) { 40 + // make sure the user actually selected a file first
  41 + // and that something was uploaded
  42 + if ( (strlen($_FILES['fFile']['name']) > 0) && $_FILES['fFile']['size'] > 0) {
42 //if the user selected a file to upload 43 //if the user selected a file to upload
43 //create the document in the database 44 //create the document in the database
44 $oDocument = & PhysicalDocumentManager::createDocumentFromUploadedFile($_FILES['fFile'], $fFolderID); 45 $oDocument = & PhysicalDocumentManager::createDocumentFromUploadedFile($_FILES['fFile'], $fFolderID);
@@ -126,7 +127,7 @@ if (checkSession()) { @@ -126,7 +127,7 @@ if (checkSession()) {
126 $default->log->error("addDocumentBL.php DB error storing document in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID"); 127 $default->log->error("addDocumentBL.php DB error storing document in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID");
127 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 128 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
128 $oPatternCustom = & new PatternCustom(); 129 $oPatternCustom = & new PatternCustom();
129 - $oPatternCustom->setHtml(getStatusPage($fFolderID, "An error occured while storing the document in the database, please try again.</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>")); 130 + $oPatternCustom->setHtml(getStatusPage($fFolderID, "An error occured while storing the document in the database, please try again.</td><td><a href=\"$default->rootUrl/control.php?action=addDocument&fFolderID=$fFolderID&fDocumentTypeID=$fDocumentTypeID\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\"></a>"));
130 $main->setCentralPayload($oPatternCustom); 131 $main->setCentralPayload($oPatternCustom);
131 $main->render(); 132 $main->render();
132 } 133 }
@@ -135,7 +136,7 @@ if (checkSession()) { @@ -135,7 +136,7 @@ if (checkSession()) {
135 $default->log->error("addDocumentBL.php Document exists with name " . $oDocument->getFileName() . " in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID"); 136 $default->log->error("addDocumentBL.php Document exists with name " . $oDocument->getFileName() . " in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID");
136 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 137 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
137 $oPatternCustom = & new PatternCustom(); 138 $oPatternCustom = & new PatternCustom();
138 - $oPatternCustom->setHtml(getStatusPage($fFolderID, "A document with this file name already exists in this folder</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>")); 139 + $oPatternCustom->setHtml(getStatusPage($fFolderID, "A document with this file name already exists in this folder</td><td><a href=\"$default->rootUrl/control.php?action=addDocument&fFolderID=$fFolderID&fDocumentTypeID=$fDocumentTypeID\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\"></a>"));
139 $main->setCentralPayload($oPatternCustom); 140 $main->setCentralPayload($oPatternCustom);
140 $main->render(); 141 $main->render();
141 } 142 }
@@ -143,7 +144,7 @@ if (checkSession()) { @@ -143,7 +144,7 @@ if (checkSession()) {
143 // no uploaded file 144 // no uploaded file
144 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); 145 require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
145 $oPatternCustom = & new PatternCustom(); 146 $oPatternCustom = & new PatternCustom();
146 - $oPatternCustom->setHtml(getStatusPage($fFolderID, "You did not select a valid document to upload</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>")); 147 + $oPatternCustom->setHtml(getStatusPage($fFolderID, "You did not select a valid document to upload</td><td><a href=\"$default->rootUrl/control.php?action=addDocument&fFolderID=$fFolderID&fDocumentTypeID=$fDocumentTypeID\"><img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\"></a>"));
147 $main->setCentralPayload($oPatternCustom); 148 $main->setCentralPayload($oPatternCustom);
148 $main->render(); 149 $main->render();
149 } 150 }