我上载档案时整个网站当机 - php

当我使用HTML表单上传文件时,一旦我点击“上传”按钮,整个网站就会崩溃。我无法在大约40分钟的时间内看到该网站,但是FTP服务器仍然可用。

我不明白为什么会这样。昨天工作正常,今天却不行。一切都没有改变。

我使用一种简单的形式:

<form enctype="multipart/form-data" action="csvupload.php" method="POST">
 <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
Upload File: <input name="csv" type="file" />
<input type="submit" value="Send File" />
 </form>

参考方案

您的php错误如何捕获文件上传?
我发现这样的代码在这些崩溃情况下可以提供很多信息。

$file=$_FILES['file'];
        if (isset($_FILES['file'])==true){
            if ($file["error"] > 0)
            {
                $errors_array = array(  0=>"There is no error, the file uploaded with success", 
                    1=>"The uploaded file exceeds the upload_max_filesize directive!", 
                    2=>"The uploaded file exceeds the MAX_FILE_SIZE directive",
                    3=>"The uploaded file was only partially uploaded", 
                    4=>"No file was uploaded",
                    5=>"Unknown Error",
                    6=>"Missing temporary folder"
                );
                $error=$file["error"];

            }
    }

避免执行move_uploaded_file。

获取PHP中函数调用者的__FILE__常量 - php

我知道PHP中的__FILE__魔术常数将变成当前执行文件的完整路径和文件名。但是,有什么方法可以使函数的调用文件获得相同的信息吗?例如://foo.php: include "bar.php"; call_it(); //bar.php function call_it() { echo "Calling file: …

PHP:从函数返回值并直接回显它? - php

这可能是一个愚蠢的问题,但是……的PHPfunction get_info() { $something = "test"; return $something; } html<div class="test"><?php echo get_info(); ?></div> 有没有办…

php-printf和sprintf具有不同的输出 - php

我编写了以下微型php程序来测试printf和sprintf:<?php $str_1 = printf("%x%x%x", 65, 127, 245); $str_2 = sprintf("%x%x%x", 65, 127, 245); echo $str_1 . "\n"; echo $s…

检查文件是否存在且大于 - php

我需要检查与脚本位于同一文件夹中的文件是否存在并且大于100字节,如果是,则回显“是否存在”。 参考方案 我相信您正在尝试执行以下操作:$filename = 'test.txt'; if (file_exists($filename) && filesize($filename) > 100) { echo �…

PHP-解析当前URL - php

在以下两种情况下,我都需要解析当前网址:http://mydomain.com/abc/ http://www.mydomain.com/abc/ 我可以获得“ abc”的返回值(或该位置的任何文本)。我怎样才能做到这一点? 参考方案 您可以使用parse_url();$url = 'http://www.mydomain.com/abc/…