2012-01-06 69 views
0

我把一个脚本放在一起,允许我将XML文件上传到mySQL数据库。我遇到的问题是,大约15秒后,我收到了 'Internet Explorer无法显示网页'“屏幕。上传文件大小和时间

因为该文件有点超过5MB我认为这个问题是在PHP中的'超时'或'filesize'问题。经过一番研究后,我想我已经找到了改变这种情况的方法,希望能让我下载这个文件,所以我在PHP脚本的顶部插入了这些行。

ini_set('max_execution_time', 300); //300 seconds = 5 minutes 
ini_set('memory_limit', '6M'); //6 MB 

我现在已经重新加载的文件,我的服务器,但我仍然得到同样的问题,我已经用完了为什么这可能会发生。

PHP代码

<? 

ini_set('max_execution_time', 300); //300 seconds = 5 minutes 
ini_set('memory_limit', '6M'); //6 MB 
    $objDOM = new DOMDocument(); 
    $objDOM->load("xmlfile.xml"); 

    $Details = $objDOM->getElementsByTagName("Details"); 

    foreach($Details as $value) 
    { 

    $listentry = $value->getElementsByTagName("listentry"); 
    $listentrys = $listentry->item(0)->nodeValue; 

    $sitetype = $value->getElementsByTagName("sitetype"); 
    $sitetypes = $sitetype->item(0)->nodeValue; 

    $sitedescription = $value->getElementsByTagName("sitedescription"); 
    $sitedescriptions = $sitedescription->item(0)->nodeValue; 

    $siteosgb36lat = $value->getElementsByTagName("siteosgb36lat"); 
    $siteosgb36lats = $siteosgb36lat->item(0)->nodeValue; 

    $siteosgb36lon = $value->getElementsByTagName("siteosgb36lon"); 
    $siteosgb36lons = $siteosgb36lon->item(0)->nodeValue; 

    //echo "$listentrys :: $sitetypes :: $sitedescriptions :: $siteosgb36lats :: $siteosgb36lons <br>"; 
require("phpfile.php"); 

//Opens a connection to a MySQL server 
$connection = mysql_connect ("hostname", $username, $password); 
if (!$connection) { 
die('Not connected : ' . mysql_error()); 
} 

// Set the active MySQL database 
$db_selected = mysql_select_db($database, $connection); 
if (!$db_selected) { 
die ('Can\'t use db : ' . mysql_error()); 
} 

mysql_query("INSERT IGNORE INTO scheduledsites (listentry, sitetype, sitedescription, siteosgb36lat, siteosgb36lon) VALUES('$listentrys','$sitetypes','$sitedescriptions','$siteosgb36lats','$siteosgb36lons') ") 
or die(mysql_error()); 

    } 

echo "Data Inserted!"; 


?> 
+0

如何将XML保存在数据库中?确保文件类型的最大大小足够大。 Blob不会,bigblob会。 – rsplak 2012-01-06 15:37:15

+0

Hi @rsplak。非常感谢您回复我的帖子。该文件最初在Excel中开始,我运行一些宏来整理我想要使用的数据。然后将该文件保存为XML数据文件并运行PHP脚本以加载到数据库中。我已将代码添加到原始帖子中。我非常确定,我上传文件的方式是可以的,因为我上传了另一个文件,虽然体积较小,而且运行没有任何问题。亲切的问候。 – IRHM 2012-01-06 15:46:26

+0

查看您的日志文件。 – 2012-01-06 15:50:51

回答

0

你可以试试这个建议我到另一StackOverflow的成员other day提供:

一下添加到一个htaccess文件:

<IfModule mod_php5.c> 
php_value post_max_size 200M 
php_value upload_max_filesize 200M 
php_value memory_limit 300M 
php_value max_execution_time 259200 
php_value max_input_time 259200 
php_value session.gc_maxlifetime 1200 
</IfModule> 

阅读更多关于那些设置在http://www.pacecode.com/blog/2008/09/22/magic-with-htaccess-file-increase-execution-time-session-expiry-time-and-file-upload-size-limit/

+0

嗨@cillosis,原谅我的要求。作为这个领域的新手,你能解释我将如何访问'htaccess'文件吗?非常感谢和亲切的问候 – IRHM 2012-01-06 16:01:04

+0

这可能更好地解释一个教程:http://www.htaccess-guide.com/ – 2012-01-06 16:03:52

+0

非常感谢。我会看一看! – IRHM 2012-01-06 18:03:36