PHP多文件上载非致命错误最大执行超时

PHP多文件上载非致命错误最大执行超时,php,file-upload,Php,File Upload,我正在尝试将多个图像上载到多个目录。我在这里真正做的是表单允许用户上传两个图像,它将使用相同名称的两个图像重命名为两个目录,并将其记录到数据库中。但是我下面的代码在处理过程中没有显示任何错误,180秒后,我在第11行(while(file_exists($target_full)){)处收到一个超过最大执行时间的错误。图像100%拍摄,但在服务器上找不到,而且也没有记录到数据库中 我用的是最简单的方法。我想问题发生在重命名文件exist中的图像时。有人能帮我解决这个问题吗 function.ph

我正在尝试将多个图像上载到多个目录。我在这里真正做的是表单允许用户上传两个图像,它将使用相同名称的两个图像重命名为两个目录,并将其记录到数据库中。但是我下面的代码在处理过程中没有显示任何错误,180秒后,我在第11行(
while(file_exists($target_full)){
)处收到一个超过最大执行时间的错误。图像100%拍摄,但在服务器上找不到,而且也没有记录到数据库中

我用的是最简单的方法。我想问题发生在重命名文件exist中的图像时。有人能帮我解决这个问题吗

function.php

<?php

$target_full = "/test/av-full/";
$target_tp   = "/test/av-tp/";
$tmp         = explode(".", $_FILES["photo_full"]["name"]);
$photo_full  = time() . '_' . rand(100, 999) . '.' . end($tmp);
$photo_tp    = "$photo_full";
$target_full = ($_SERVER['DOCUMENT_ROOT'] . "/test/av-full/");
$target_tp   = ($_SERVER['DOCUMENT_ROOT'] . "/test/av-tp/");

while (file_exists($target_full)) {
    $tmp         = explode(".", $_FILES["photo_full"]["name"]);
    $photo_full  = time() . '_' . rand(100, 999) . '.' . end($tmp);
    $target_full = ($_SERVER['DOCUMENT_ROOT'] . "/test/av-full/");
}
while (file_exists($target_tp)) {
    $photo_tp  = "$photo_full";
    $target_tp = ($_SERVER['DOCUMENT_ROOT'] . "/test/av-tp/");
}

$con = mysqli_connect("localhost", "username", "password") or die("MySQL Login problem!");
mysqli_select_db($con, "database") or die("Could not connect to database!");


if (move_uploaded_file($_FILES['photo_full']['tmp_name'], $target_full)) {
    if (move_uploaded_file($_FILES['photo_tp']['tmp_name'], $target_tp)) {

        mysqli_query($con, "INSERT INTO table (photo_full,photo_tp)
            VALUES ('$photo_full','$photo_tp')");

    } else {
        echo "photo 340px error.";
    }
    echo "The file <b>" . basename($_FILES['photo_full']['name']) . "</b> & <b>" . basename($_FILES['photo_tp']['name']) . "</b> has been uploaded, and renamed to <b>$photo_tp</b>. This is for your information.";
} else {
    echo "error occured";
}
?> 
<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <form action="function.php" enctype="multipart/form-data" method="post">
        <label>upload image to database</label><br>
        <br>
        <label>full size image :</label> <input name="size" type="hidden" value="350000"> <input name="photo[]" type="file"><br>
        <br>
        <label>340px size image :</label> <input name="size" type="hidden" value="350000"> <input name="photo[]" type="file"><br>
        <br>
        <br>
        <input name="upload" title="Add data to the Database" type="submit" value="Add Member">
    </form>
</body>
</html>

回答您的问题“我的代码中是否缺少任何内容?”:当然,可能有。我们只能说一点,因为我们不知道您预期会发生什么。@RaxShah我不这么认为,这是时间问题,因为文件上载是在10秒内完成的。那么最有可能的一个循环是无止境的循环。开始记录进度标记。@arkascha我在顶部解释说,我正在尝试将两个图像上载到两个目录。据我所知,由于您基于当前时间的最终文件名,您可以保证这些文件不存在。因此,您不必检查。要回答您的问题“我的代码中是否缺少任何内容?”:当然,可能有。我们只能说一点,因为我们不知道您预期会发生什么。@RaxShah我不这么认为,这是时间问题,因为文件上载是在10秒内完成的。那么最有可能的一个循环是无止境的循环。开始记录进度标记。@arkascha我在顶部解释说,我正在尝试将两个图像上载到两个目录。由于您基于当前时间的最终文件名,据我所知,您可以保证这些文件不存在。因此您不必进行检查。