我正在为我的用户构建一个 pdf 转换实用程序。我正在工作,CakePhp
我的控制器正在接收 Ajax 调用。为什么我收到通知:8错误
控制器:
public function convertToPdf() {
$this->autoRender = false;
$pdf = new WkHtmlToPdf;
//$this->RequestHandler->respondAs('json');
// echo $convertData = json_encode($inputVal);
if ($this->RequestHandler->isAjax()) {
$pdfName = uniqid();
if ($_FILES['conversionSourceFile']) {
echo "File";
$pdf->addPage($_FILES['conversionSourceFile']['tmp_name']);
} elseif ($_POST['conversionSourceUrl']) {
echo "Url";
$pdf->addPage($_POST['conversionSourceUrl']);
} elseif ($_POST['conversionSourceHtml']) {
echo "Html";
$pdf->addPage('<html>' . $_POST['conversionSourceHtml'] . '</html>');
}
$saveToPath = 'upload/' . $pdfName . '.pdf';
if ($pdf->saveAs($saveToPath)) {
echo 'upload/' . $pdfName . '.pdf';
}
}
}
错误: 注意(8):未定义索引:conversionSourceFile [APP/Controller/PdfsController.php, line 42] 代码上下文
if ($this->RequestHandler->isAjax()) {
$pdfName = uniqid();
if ($_FILES['conversionSourceFile']) {
PdfsController::convertToPdf() - APP/Controller/PdfsController.php, line 42
ReflectionMethod::invokeArgs() - [internal], line ??
Controller::invokeAction() - CORE/Cake/Controller/Controller.php, line 486
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 187
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 162
[main] - APP/webroot/index.php, line 109