远程服务器返回错误:(500)内部服务器错误 [英] The remote server returned an error : (500) internal server error

查看:1390
本文介绍了远程服务器返回错误:(500)内部服务器错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用php程序从debian Linux服务器下载csv数据文件。它工作正常。当数据文件的数量增加时,会发生错误。任何专家都可以提供帮助吗?



我在服务器中的download.php程序如下:



< ?php

$ the_folder ='/ home / debian / dcuproc / data';

$ zip_file_name ='./download/data_dcuproc.zip';



类FlxZipArchive扩展ZipArchive {

公共函数addDir($ location,$ name){

$ this-> addEmptyDir( $ name);

$ this-> addDirDo($ location,$ name);

} // EO addDir;



私人函数addDirDo($ location,$ name){

$ name。='/'; $ location。='/';

//读取目录中的所有文件

$ dir = opendir($ location);

while( $ file = readdir($ dir)){

如果($ file =='。'|| $ file =='..')继续;

// Rekursiv,if dir:FlxZipArchive :: addDir(),else :: File();

$ do =(filetype($ location。$ file)=='dir')? 'addDir':'addFile';

$ this-> $ do($ location。$ file,$ name。$ file);

}

}

}



$ za =新的FlxZipArchive;

$ res = $ za- >打开($ zip_file_name,ZipArchive :: CREATE);

if($ res === TRUE){

$ za-> addDir($ the_folder,basename) ($ the_folder)); $ za> close();

}

else {

echo'无法创建zip存档';

}



header('Content-Description:File Transfer');

header('Content-Type:application / octet-stream');

header('Content-Disposition:attachment; filename = data.zip');

header('Content-Transfer-Encoding:binary' );

header('Expires:0');

header('Cache-Control:must-revalidate');

header( 'Pragma:public');

header('Content-Length:'。filesize($ zip_file_name));

ob_clean();

flush();

if(readfile($ zip_file_name))

{

unlink($ zip_file_name);

}



?>



我尝试了什么:



我试图减少文件数量。有用。但我们实际上需要通过从PC调用download.php来压缩大量文件并将其下载到PC。

I used a php program for downloading csv data file from a debian Linux server. It was working fine. When the number of data files are increased, the error occurs. Any expert can help ?

My download.php program in Server is listed below :

<?php
$the_folder = '/home/debian/dcuproc/data';
$zip_file_name = './download/data_dcuproc.zip';

class FlxZipArchive extends ZipArchive {
public function addDir($location, $name) {
$this->addEmptyDir($name);
$this->addDirDo($location, $name);
} // EO addDir;

private function addDirDo($location, $name) {
$name .= '/'; $location .= '/';
// Read all Files in Dir
$dir = opendir ($location);
while ($file = readdir($dir)) {
if ($file == '.' || $file == '..') continue;
// Rekursiv, If dir: FlxZipArchive::addDir(), else ::File();
$do = (filetype( $location . $file) == 'dir') ? 'addDir' : 'addFile';
$this->$do($location . $file, $name . $file);
}
}
}

$za = new FlxZipArchive;
$res = $za->open($zip_file_name, ZipArchive::CREATE);
if($res === TRUE) {
$za->addDir($the_folder, basename($the_folder)); $za->close();
}
else {
echo 'Could not create a zip archive';
}

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=data.zip');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($zip_file_name));
ob_clean();
flush();
if (readfile($zip_file_name))
{
unlink($zip_file_name);
}

?>

What I have tried:

I have tried to reduce the number of files. It works. But we actually need to zip large number of files and download it to PC by calling download.php from PC.

推荐答案

the_folder ='/ home / debian / dcuproc / data';
the_folder = '/home/debian/dcuproc/data';


zip_file_name ='./download/data_dcuproc.zip';



类FlxZipArchive扩展ZipArchive {

公共函数addDir(
zip_file_name = './download/data_dcuproc.zip';

class FlxZipArchive extends ZipArchive {
public function addDir(


location,


这篇关于远程服务器返回错误:(500)内部服务器错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆