Php iphone在提交表单时失去网络连接

Php iphone在提交表单时失去网络连接,php,iphone,forms,Php,Iphone,Forms,我有一个详细信息和附件的上传表格 它在桌面上运行良好,但当我在iphone4和5上尝试时,我点击了upload,它只是说safari无法打开页面,因为网络连接丢失了 我的表单将文档保存到文件夹中,并上传到MySQL数据库 有什么想法吗 Upload\u portal.php: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-

我有一个详细信息和附件的上传表格

它在桌面上运行良好,但当我在iphone4和5上尝试时,我点击了upload,它只是说safari无法打开页面,因为网络连接丢失了

我的表单将文档保存到文件夹中,并上传到MySQL数据库

有什么想法吗

Upload\u portal.php:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>upload Portal</title>

    <!-- Bootstrap -->
     <link rel="stylesheet" type="text/css" href="css/bootstrap.css">

    <link rel="stylesheet" type="text/css" href="css/main.css">




    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
      <div class="row">
        <div class="col-sm-12">
            <img src="img/logo.jpg" />
        </div>
      </div><!-- END ROW -->
      <div class="row">
        <div class="col-sm-12 topBar">
            <h1>
              Premium Choice Upload portal
            </h1>
            <p>
              Welcome to the Premium Choice upload portal where you can securely send us all your documents. You can also request a copy of your documents
            </p>
        </div>
      </div><!-- END ROW -->
      <div class="clearfix"></div>
      <div class="container">
        <div class="row">
          <form action="upload.php" method="post" enctype="multipart/form-data">
          <div class="col-lg-6 col-md-6" style="font-size:1.2em;"><!-- THIS IS THE 1st section -->
            <div class="col-xs-12 sectionHeader">
              <h2> Section 1: Personal Details </h2>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 colClear">
              Select your type of policy:<strong style="color:red; font-size:1.2em;">*</strong>
            </div>
            <div class="col-lg-6  col-md-6 col-sm-6 col-xs-12 colClear">
              <select class="select" name="pol_type"> 
                <option selected="selected" value="Private Car">Private Car</option>
                <option value="Commercial Vehicle">Commercial Vehicle</option>
                <option value="Motorcycle">Motorcycle</option>   
              </select> 
            </div>
            <div class="col-xs-12" style="padding:0;">
                <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 colClear">
                Customer reference <strong style="color:red; font-size:1.2em;">*</strong><br/>
                <input id="reference" type="text" name="reference" value="<?php echo $_GET['ref']; ?>"/>
                </div>
                <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 colClear">
                    Email Address <strong style="color:red; font-size:1.2em;">*</strong><br/>
                  <input id="email" type="text" name="email"/>
                </div>
            </div>
            <?php
                                if(!empty($_SESSION['errors'][1])){
                                    $output =  "<div class='col-xs-12' style='color:red;'>";


                                    $output .= $_SESSION['errors'][1];


                                    $output .= "</div>";
                                    echo $output;
                                }
            ?>

            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 colClear">
              First Name <strong style="color:red; font-size:1.2em;">*</strong><br/>
              <input id="firstName" type="text" name="first_name"/>
            </div>
            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 colClear">
              last Name <strong style="color:red; font-size:1.2em;">*</strong><br/>
              <input id="lastName" type="text" style="float:right;" name="last_name"/>
            </div>
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 colClear" style="padding:0;">
              <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                Vehicle registration <strong style="color:red; font-size:1.2em;">*</strong><br/>
                <input id="reg" type="text" name="registration"/>
              </div>
              <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                Contact Number <strong style="color:red; font-size:1.2em;">*</strong><br/>
                <input id="number" type="text" style="float:right;" name="number"/>
              </div>
            </div>

          </div>
          <div class="col-lg-6 col-md-6"><!-- THIS IS THE 2nd section -->
            <div class="col-xs-12 sectionHeader">
              <h2> Section 2: Send us your documents online</h2>
            </div>
            <div class="col-lg-12 text-center" style="font-size:0.9em;">
              <p class="colClear">Attach your scanned documents as JPG,PDF,DOC,TIF,PNG,GIF (Maximum 20MB)</p>
            </div>
            <div class="col-lg-10 col-sm-offset-2 uploadSection">
              <div class="col-xs-12 colClear">
                <input class="colClear" type="file" size="40" name="pictures[]" />

              </div>
              <div class="col-xs-12 colClear">
                <input class="colClear" type="file" size="40" name="pictures[]" />

              </div>
              <div class="col-xs-12 colClear">
                <input class="colClear" type="file" size="40" name="pictures[]" />

              </div>
              <div class="col-xs-12 colClear">
                <input class="colClear" type="file" size="40" name="pictures[]" />

              </div>
              <div class="col-xs-12 colClear">
                <input class="colClear" type="file" size="40" name="pictures[]" />

              </div>
            </div>

          </div>
        </div><!-- END OF ROW -->
        <div class="colClear"></div>
        <div class="colClear"></div>
        <div class="row">
          <div class="col-lg-6 col-md-6">
            <div class="col-lg-12 sectionHeader colClear">
              <h2> Section 3: Request a copy of your documents</h2>
            </div>
            <div class="col-lg-12 text-center" style="font-size:1em;">
              <p>Do you have any other queries or copy document requests?</p>
            </div>
            <div class="col-lg-12">
              <textarea name="comments">

              </textarea><br/><br/>
              <p class="text-center" style="font-size:0.75em;">We are unable to send any documents via email. If you have requested such items, these will follow via first</p>
            </div>
          </div>
          <div class="col-lg-6 col-md-6">
            <div class="col-lg-12 sectionHeader colClear">
              <h2 class="text-center"> Submit your request </h2>
            </div>
            <div class="col-lg-12 colClear">
              <input type="submit" class="button colClear" value="" />   
                <p style="font-size:0.75em;">
                    <strong>Please Note</strong><br>
                    Our office hours are 9am-8pm Mon-Fri & 9am-3pm Sat which means any requests submitted outside of these hours will be dealt with the next working day.<br/><br/>
                    Photographs taken with a low resolution camera are not acceptable and we may also ask you to send us the original proof in the post. 

                </p>
              </form>
            </div>
          </div>
        </div>
      </div>


    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
</html>
<?php
session_start();
$_SESSION['errors'] = array();
require_once("includes/db_connection.php");
require_once("includes/functions.php");
require_once("Mail.php");
require_once("Mail/mime.php");

    $errors = array();

    //Variables from $_POST
        $ref = mysql_prep($_POST['reference']);
        $type = mysql_prep($_POST['pol_type']);
        $first_name = mysql_prep($_POST['first_name']);
        $last_name = mysql_prep($_POST['last_name']);
        $reg = mysql_prep($_POST['registration']);
        $number = mysql_prep($_POST['number']);
        $email = mysql_prep($_POST['email']);    
        $comments = mysql_prep($_POST['comments']);
        $date = date("d/m/Y");
        $full_name = $first_name . " " . $last_name;
    //Validations:
        //1) There needs to be at least one upload
        $total_files = count(array_filter($_FILES['pictures']['name']));
        if($total_files < 1)
        {
            $_SESSION['errors'][0] = "No files have been uploaded!";
        }
        //2) Reference needs to be certain length
        if(strlen($ref) !== 8)
        {
            $_SESSION['errors'][1] = "client reference must be a number, and must be 8 digits long";
        }
        //3) All Fields need to be filled
        if($type == "" || $first_name == "" || $last_name == "" || $reg == "" || $number == "" || $email == "")
        {
            $_SESSION['errors'][2] = "All Fields must have a value!";
        }
        //3) Email must be valid
        if(!filter_var($email, FILTER_VALIDATE_EMAIL))
        {
            $_SESSION['errors'][4] = "Email must be valid";
        }   
        //4) Files size limit to 20MB
        $total_size = 0;
        foreach ($_FILES["pictures"]["size"] as $size) 
        {
            $total_size = $total_size + $size;  
        }        
            if($total_size > 1e+7)
            {
                $_SESSION['errors'][3] = "File size limit is 20MB, your files are too big!";
            }























// If there are no errors in the validation then continue with script
if(empty($_SESSION['errors']))
{

    //Calls the function to upload the files/details to database, (Requires post variables);
    //insert_upload($ref,$type,$first_name,$last_name,$reg,$number,$email,$comments,$connection);

    $img_count = 0;
    $img_name1 = "";
    $img_name2 = "";
    $img_name3 = "";
    $img_name4 = "";
    $img_name5 = "";
    $newimg_count = 0;
    $newimg_name1 = "";
    $newimg_name2 = "";
    $newimg_name3 = "";
    $newimg_name4 = "";
    $newimg_name5 = "";
            //Foreach files uplaoded place the file name into variable to go into table for later reference.
            foreach ($_FILES["pictures"]["name"] as $key => $Name) 
            {
                $img_count++;
                    if($img_count == 1)
                    {
                        $img_name1 = $_FILES["pictures"]["name"][$key];
                        if($img_name1 !== "")
                        {
                            $newimg_count++;
                            $newimg_name1 = $newimg_count . $img_name1;
                        }else
                        {
                            $newimg_name1 = $img_name1;
                        }   
                        echo $newimg_name1; 
                    }elseif($img_count == 2)
                    {
                        $img_name2 = $_FILES["pictures"]["name"][$key];
                        if($img_name2 !== "")
                        {
                            $newimg_count++;
                            $newimg_name2 = $newimg_count . $img_name2;
                        }else
                        {
                            $newimg_name2 = $img_name2;
                        }   
                        echo $newimg_name2; 
                    }elseif($img_count == 3)
                    {
                        $img_name3 = $_FILES["pictures"]["name"][$key];
                        if($img_name3 !== "")
                        {
                            $newimg_count++;
                            $newimg_name3 = $newimg_count . $img_name3;
                        }else
                        {
                            $newimg_name3 = $img_name3;
                        }   
                        echo $newimg_name3; 
                    }elseif($img_count == 4)
                    {
                        $img_name4 = $_FILES["pictures"]["name"][$key];
                        if($img_name4 !== "")
                        {
                            $newimg_count++;
                            $newimg_name4 = $newimg_count . $img_name4;
                        }else
                        {
                            $newimg_name4 = $img_name4;
                        }
                        echo $newimg_name4; 
                    }else
                    {
                        $img_name5 = $_FILES["pictures"]["name"][$key];
                        if($img_name5 !== "")
                        {
                            $newimg_count++;
                            $newimg_name5 = $newimg_count . $img_name5;
                        }else
                        {
                            $newimg_name5 = $img_name5;
                        }
                        echo $newimg_name5; 
                    } 
            }   
    $query =  "INSERT INTO ";
    $query .= "customers";  
    $query .= "(`reference`, `policy_type`, `first_name`, `last_name`, `registration`, `number`, `email`, `doc1`, `doc2`, `doc3`,`doc4`,`doc5`,`comments`,`date`) ";
    $query .= "VALUES ('{$ref}', '{$type}', '{$first_name}', '{$last_name}' , '{$reg}' , '{$number}' , '{$email}' , '{$newimg_name1}' , '{$newimg_name2}' , '{$newimg_name3}', '{$newimg_name4}', '{$newimg_name5}','{$comments}','{$date}')";
    $result = mysqli_query($connection, $query);
    $_SESSION['query'] = $query;



























    $target_dir = "docs/";

    //IF/ELSE the folder is already created...
        if(!file_exists($target_dir . $ref . "/"))
        {//Create folder named 1 inside the customer ref folder.
            mkdir($target_dir . $ref . "/" . "1" . "/", 0775, true);
            $count = 0;
        }else
        {//Create new folder inside customer ref folder 
            //count the amount of folders inside docs/$ref/
            $find_folders = glob($target_dir . $ref . "/" . "*",GLOB_ONLYDIR);
            $count = count($find_folders);
            //create new folder inside $ref/ using count+1 to make the folder increase by 1
                $new_folder = $count +1;
                mkdir($target_dir . $ref . "/" . $new_folder . "/", 0775, true);        
        }
                //IF count exists then the $target_file changes to the new folder...
                    if($count > 0)
                        {
                            $target_file = $target_dir . $ref . "/" . $new_folder . "/";  
                        }else
                        {//else use first directory
                            $target_file = $target_dir . $ref . "/" . "1" . "/";
                        }
    //Loop through files and place them into $target_file...
        $namecount = 0;
        foreach ($_FILES["pictures"]["name"] as $key => $Name) 
        {

                $tmp_name = $_FILES["pictures"]["tmp_name"][$key];
                $name = $_FILES["pictures"]["name"][$key];
                if($name !== ""){
                    $namecount++;
                    $newname = $namecount . $name;
                }else{
                    $newname = $name;
                }
                echo $newname . "</br>";
                move_uploaded_file($tmp_name, $target_file . "$newname");

        }





$from = " Upload portal <upload-portal@premiumchoiceinsurance.co.uk>";
$to = "Matthew <matthew.smart@premiumchoice.co.uk>";
$subject = "Document Upload, Policy: 123456789";
$host = "ssl://secure.emailsrvr.com";
$port = "465";
$username = "upload-portal@premiumchoiceinsurance.co.uk";
$password = "C4r1n5ur4nc3";
$crlf = "\n";
$web_root = "http://test.premiumchoiceinsurance.co.uk.php54-3.dfw1-2.websitetestlink.com/";
$link1 = "<a href='" . $web_root . $target_file . $newimg_name1 . "'>{$img_name1}</a>";
$link2 = "<a href='" . $web_root . $target_file . $newimg_name2 . "'>{$img_name2}</a>";
$link3 = "<a href='" . $web_root . $target_file . $newimg_name3 . "'>{$img_name3}</a>";
$link4 = "<a href='" . $web_root . $target_file . $newimg_name4 . "'>{$img_name4}</a>";
$link5 = "<a href='" . $web_root . $target_file . $newimg_name5 . "'>{$img_name5}</a>";


$html = "
<html>
<head>

</head>
<body>
<div style='width:100%;height:500px;'>
    <p>This email was made from the Document Upload Portal</p>

    <table style='width:400px;'>
        <tr style='background-color:#FFFFCC; height:50px;'>
            <td style='text-align:center;'>
                Customer reference: 
            </td>
            <td style='text-align:center;'>
                {$ref}
            </td>
        </tr>
        <tr style='background-color:#CCCCB2; height:50px;'>
            <td style='text-align:center;'>
                Policy Type: 
            </td>
            <td style='text-align:center;'>
                {$type}
            </td>
        </tr>
        <tr style='background-color:#FFFFCC; height:50px;'>
            <td style='text-align:center;'>
                Vehicle Registration 
            </td>
            <td style='text-align:center;'>
                {$reg}
            </td>
        </tr>
        <tr style='background-color:#CCCCB2; height:50px;'>
            <td style='text-align:center;'>
                name: 
            </td>
            <td style='text-align:center;'>
                {$full_name}
            </td>
        </tr>
        <tr style='background-color:#FFFFCC; height:50px;'>
            <td style='text-align:center;'>
                telephone:
            </td>
            <td style='text-align:center;'>
                {$number}
            </td>
        </tr>
        <tr style='background-color:#CCCCB2; height:50px;'>
            <td style='text-align:center;'>
                Email:
            </td>
            <td style='text-align:center;'>
                {$email}
            </td>
        </tr>
        <tr style='background-color:#FFFFCC; height:50px;'>
            <td style='text-align:center;'>
                Attached Files:
            </td>
            <td style='text-align:center;'>
                {$link1}<br/>
                {$link2}<br/>
                {$link3}<br/>
                {$link4}<br/>
                {$link5}<br/>

            </td>
        </tr> 
    </table>
    <table style='width:400px;'>
        <tr style='background-color:#CCCCB2; height:50px;'>
            <td style='text-align:center;'>
                Comments:<br/><br/>
                {$comments}
            </td>
        </tr>
    </table>
</div>

</body>
</html>
";
$headers = array (
              'From' => $from,
              'To' => $to,
              'Subject' => $subject
          );

$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'port' => $port,
    'auth' => true,
    'username' => $username,
    'password' => $password,
    'MIME-Version' => 1,
    'Content-type' => 'text/html;charset=iso-8859-1'
    ));


        $mime = new Mail_mime($crlf);

        // Setting the body of the email

        $mime->setHTMLBody($html);

        $body = $mime->get();
        $headers = $mime->headers($headers);


$mail = $smtp->send($to, $headers, $body);




        echo '<script type="text/javascript">
           window.location = "http://test.premiumchoiceinsurance.co.uk.php54-3.dfw1-2.websitetestlink.com/thanks.php"
      </script>';

}else//if there are errors in validation then redirect to index and show them
{
    redirect_to('upload_portal.php?ref=' . $ref);
}//END OF empty session




?>

上载门户
高级选择上传门户

欢迎使用Premium Choice上载门户,您可以安全地向我们发送您的所有文档。您还可以要求提供您的文档副本

第1节:个人详细信息 选择您的策略类型:* 私家车 商用车 摩托车 客户参考*

当我将图像从iphone上传到nginx(即aws beanstalk)后面的服务器时,我得到一个“Safari无法加载页面,因为网络连接丢失”和chrome“无法连接到互联网”。结果表明,该图像大于1M nginx客户端的默认大小。(似乎在桌面上工作,这很奇怪。)我的解决方案是将参数值增加到更合适的值

在beanstalk上,解决方案是在分发文件的根目录下创建一个名为.ebextensions的文件夹,并将名为nginx.config的文件(仅以.config结尾)放入以下代码中:

文件夹:
/etc/nginx/conf.d/proxy.conf:
内容:|
客户的最大车身尺寸为50M;

虽然我有很多代码,但如果您需要,我可以全部添加?我只是想问一下,万一有一个已知的问题,我们就不会读代码了。将现有的样本减少到导致相同问题的最小样本。e、 如果你有500个表单字段,但是同一个表单只有一个字段会触发相同的问题,那么我们就不需要其他499个(无用的)html。我已经更新了注释