gpt4 book ai didi

javascript - Ajax uploader 错误500

转载 作者:行者123 更新时间:2023-12-03 08:13:48 30 4
gpt4 key购买 nike

我的页面上有一个 Ajax uploader 。从昨天开始就运作良好。现在我收到错误 500。在控制台中显示

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

并引用我的上传脚本:

  <?php
// A list of permitted file extensions
$allowed = array('html','htm');

function save_table_to_json ( $in_file, $out_file ) {
$html = file_get_contents( $in_file );
file_put_contents( $out_file, convert_table_to_json( $html ) );
}

function convert_table_to_json ( $html ) {
$document = new DOMDocument();
$document->loadHTML( $html );

$xpath = new DomXPath($document);
$tables = $xpath->query("//*[contains(@class, 'mon_list')]");
$tableDom = new DomDocument();
$tableDom->appendChild($tableDom->importNode($tables->item(0), true));

$obj = [];
$jsonObj = [];
$th = $tableDom->getElementsByTagName('th');
$td = $tableDom->getElementsByTagName('td');
$thNum = $th->length;
$arrLength = $td->length;
$rowIx = 0;

for ( $i = 0 ; $i < $arrLength ; $i++){
$head = $th->item( $i%$thNum )->textContent;
$content = $td->item( $i )->textContent;
$obj[ $head ] = $content;
if( ($i+1) % $thNum === 0){
$jsonObj[++$rowIx] = $obj;
$obj = [];
}
}

return json_encode([ "Values" => $jsonObj ]);
}


if(isset($_FILES['upl']) && $_FILES['upl']['error'] == 0){

$extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION);

if(!in_array(strtolower($extension), $allowed)){
echo '{"status":"error1"}';
exit;
}

if(move_uploaded_file($_FILES['upl']['tmp_name'], $_FILES['upl']['name'])){
save_table_to_json( 'heute_S.htm', 'heute_S.json' );
save_table_to_json( 'heute_L.htm', 'heute_L.json' );
save_table_to_json( 'morgen_S.htm', 'morgen_S.json' );
save_table_to_json( 'morgen_L.htm', 'morgen_L.json' );
echo '{"status":"success1"}';
}else{
echo '{"status":"error"}';
exit;
}
}

我没有更改服务器上的任何内容。在服务器合法只说有错误 500。

但是我该如何解决这个问题?

<小时/>

编辑:

在日志中显示:

[Wed Dec 02 17:31:26.625826 2015] [fcgid:warn] [pid 11680] [client IP] mod_fcgid: stderr: PHP Warning: DOMDocument::loadHTML(): Empty string supplied as input in /upload.php on line 12, referer: /

第二个:

[Wed Dec 02 17:31:26.625830 2015] [fcgid:warn] [pid 11680] [client IP] mod_fcgid: stderr: PHP Catchable fatal error: Argument 1 passed to DOMDocument::importNode() must be an instance of DOMNode, null given, called in /upload.php on line 7 and defined in /upload.php on line 17, referer: /

最佳答案

检查您的网络服务器错误日志。根据网络服务器的不同,应该位于/var/log/apache 或/var/log/nginx 中。

这些将为您提供有关实际问题所在的信息,并且您应该能够轻松地解决问题。

关于javascript - Ajax uploader 错误500,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34038178/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com