Пример #1
0
    $filenameTemp = transformFilename($_FILES['file']['name'], $_POST['pkId']);
    $log->debug("The FileMaker temporary name " . $filenameTemp);
    if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploadDir . $filenameTemp)) {
        $log->error("Error uploading file: " . $_FILES['file']['name']);
        outputJSON("Error uploading file: " . $_FILES['file']['name']);
    }
    $log->debug("Copied temp file name: " . $_FILES['file']['tmp_name'] . " to file " . $filenameTemp);
    pushImageToFM($originalFileName, $filenameTemp, $pkId);
    $containerUrl = getFileContainerURL($pkId, $originalFileName);
    $containerStatus = "";
    if (empty($containerUrl)) {
        $containerStatus = "empty";
    } else {
        $containerStatus = "have_url";
    }
    returnJsonToAjax("success", $containerStatus, $containerUrl, $originalFileName);
}
function getFileContainerURL($pkId, $originalName)
{
    global $log, $fmOrderDB;
    $metaFind = $fmOrderDB->newFindCommand('[WEB] Project Meta Fields');
    $metaFind->addFindCriterion('__pk_ID', '==' . $pkId);
    $metaResults = $metaFind->execute();
    if (FileMaker::isError($metaResults)) {
        $errorTitle = "Failed To Upload File";
        $error = "Meta Search Results Error: " . $metaResults->getMessage() . " " . $metaResults - getCode();
        $log->error($error);
        processError("Failed in get conatiner URL: " . $originalName, $metaResults->getMessage(), "imageUploader.php", $pkId, $errorTitle);
        exit;
    }
    $metaRelatedRecords = $metaResults->getRecords();
Пример #2
0
    $status = "error";
    die;
}
$metaFind = $fmOrderDB->newFindCommand('[WEB] Project Meta Fields');
$metaFind->addFindCriterion('__pk_ID', '==' . $pkId);
$metaResults = $metaFind->execute();
if (FileMaker::isError($metaResults)) {
    $errorTitle = "Failed To Upload File";
    $error = "Meta Search Results Error: " . $metaResults->getMessage() . " " . $metaResults - getCode();
    $log->error($error);
    $status = "error";
    processError("Failed in get conatiner URL: " . $originalName, $metaResults->getMessage(), "imageUploader.php", $pkId, $errorTitle);
    exit;
}
$metaRelatedRecords = $metaResults->getRecords();
$metaRecord = $metaRelatedRecords[0];
$containerUrl = $metaRecord->getField('Answer_Container_Data_r');
$originalFileName = $metaRecord->getField('Upload_Filename_Original_t');
$containerStatus = "";
if (empty($containerUrl)) {
    $containerStatus = "empty";
} else {
    $containerStatus = "have_url";
}
returnJsonToAjax($status, $containerStatus, $containerUrl, $originalFileName);
//function to return a json array for calling JQuery call
function returnJsonToAjax($status, $containerStatus, $urlToUse, $fileName)
{
    $responseArray = array("status" => $status, "container_status" => $containerStatus, "container_url" => $urlToUse, "filename" => $fileName);
    echo utf8_encode(json_encode($responseArray));
}