setErrorCode("4110");
//}
//else
if (is_uploaded_file($_FILES['softwareUpdate']['tmp_name']))
{
// CMIResult::FirmwareUpdateInProgress = 4125
set_single_user_mode($user, true, 4125);
// Now lets verify that the file is good by running a "tar tzf" on it
$sRet = system("tar tzf $tmp_name", $iRet);
error_log("Call to system (tar) returned a \"$iRet\" and the output was \"$sRet\"");
if ($iRet == 0)
{
// Now lets verify that the file is good again by running a "gunzip -t" on it
$sRet = system("gunzip -tv $tmp_name", $iRet);
error_log("Call to system (gunzip -tv) returned a \"$iRet\" and the output was \"$sRet\"");
}
if ($iRet != 0)
{
set_single_user_mode($user, false);
error_log("Uploaded file was corrupt");
$status->setErrorCode("4112");
$errorCode = 4112;
$returnMessage = "The uploaded file was corrupt. Please verify that the file is in the "
." the correct file format.
";
}
else
{
// Create the upload directory. This became an issue wene people were deleting this
// directory and uploads started to fail.
$sRet = system("mkdir /home/embedded/library/upload", $iRet);
error_log("Call to system (mkdir) returned a \"$iRet\" and the output was \"$sRet\"");
error_log("\n\n*******************************************************************\n*\n*" .
" The file has been uploaded. We are now going to move it to /home/embedded/library/upload" .
"*\n*\n*******************************************************************\n\n" );
if (move_uploaded_file($_FILES['softwareUpdate']['tmp_name'], "/home/embedded/library/upload/library.tgz"))
{
error_log("Moved the uploaded file to home/embedded/upload");
error_log("The file tested good - The upload is complete and finished!!!");
}
else
{
set_single_user_mode($user, false);
error_log("Failed to moved the uploaded file to images");
$status->setErrorCode("4108");
$returnMessage = "Moving the uploaded file to the appropriate directory has failed.
";
}
$errorCode = $status->errorCode;
}
}
else
{
if (is_null($_FILES["softwareUpdate"]))
{
error_log("The file is too big. softwareUpdate was NULL");
$status->setErrorCode("4109");
$returnMessage = "The file was not found. The file may be too big.";
}
else
{
switch ($HTTP_POST_FILES['softwareUpdate']['error'])
{
case 1 : //uploaded file exceeds the upload_max_filesize directive in php.ini
case 2 : //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
error_log("The file you are trying to upload is too big.");
$status->setErrorCode("4109");
$returnMessage = "The file you are trying to upload is too big.
";
break;
case 3 : //uploaded file was only partially uploaded
error_log("The file you are trying upload was only partially uploaded.");
$status->setErrorCode("4110");
$returnMessage = "The file you are trying to upload was only partially uploaded.
";
break;
case 4 : //no file was uploaded
error_log("You must select an image for upload.");
$status->setErrorCode("4111");
$returnMessage = "The file you are trying to upload was not found.
";
break;
default : //a default error, just in case! :)
error_log("There was a problem with your upload.");
$status->setErrorCode("4108");
$returnMessage = "There was a problem with your upload.
";
break;
}
}
$errorCode = $status->errorCode;
//return;
}
}
$url = 'unknown';
$filename = 'sl_lib_firmware_set.htm';
$line = 'unknown';
$symbols = 'none';
$returnMessage = $returnMessage."
File you are trying to upload: ".$_FILES['softwareUpdate']['name'];
?>