2015-02-03 3 views
1

У меня есть форма для загрузки для деталей и вложений.iphone потеря сетевого подключения при отправке формы

он прекрасно работает на рабочем столе, однако, когда я пытаюсь это на моем iphone4 и 5 я ударил загрузки, и он просто говорит, что сафари не может открыть страницу, так как соединение с сетью потеряно ...

моя форма сохраняет документы к папку и загружает в базу данных MySQL

любые идеи?

Upload_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> 

upload.php (форма proccess файл):

<?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 <[email protected]>"; 
$to = "Matthew <[email protected]>"; 
$subject = "Document Upload, Policy: 123456789"; 
$host = "ssl://secure.emailsrvr.com"; 
$port = "465"; 
$username = "[email protected]"; 
$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 




?> 
+0

У меня есть много кода, хотя, я могу добавить все это, если вы хотите? я просто, хотя id ask incase был известная проблема –

+0

, мы не собираемся читать стену кода. уменьшите то, что у вас есть, к самому маленькому образцу, который вызывает ту же проблему. например если у вас есть 500 полей формы, но одна и та же форма с одним полем запускает один и тот же пробник, тогда нам не нужны другие 499 (бесполезные) бит html. –

+0

У меня есть обновленные заметки –

ответ

0

При размещении изображения с айфона на сервере за Nginx (т.е. AWS beanstalk), я получил, что у меня «Safari не может загрузить страницу, потому что сетевое соединение было потеряно» и хром «не удалось подключиться к Интернету». Оказывается, изображение было больше, чем 1M nginx по умолчанию для client_max_body_size. (Кажется, работает на рабочем столе, что странно.) Решение для меня состояло в том, чтобы увеличить значение этого параметра до более подходящего.

На Beanstalk, решение создать папку в корне файла распределения называемых .ebextensions и поместить файл с именем nginx.config (только вопросы, она заканчивается .config) с помощью следующего кода: files: /etc/nginx/conf.d/proxy.conf: content: | client_max_body_size 50M;

Смежные вопросы