2017-04-23 6 views
-2

htdocsの下に "try"というフォルダがあり、PHPファイルをhtmlに接続しますが、phpファイルは含まれません。私のコードに何か問題がありますか?htmlコードにPHPファイルを含めるには

<?php 

include 'init.inc.php'; 

?> 

htmlファイルとphpファイルは、「try」フォルダ内にあります。私を許して私はちょうど初心者です! index.htmlのため

+0

サーバ上の 'try'の絶対パスは何ですか? –

+0

あなたはそれが含まれていないことをどのように知っていますか?エラーメッセージはありますか? – Pharaoh

+0

c:/ xampp/htdocs/try –

答えて

0

コード:init.inc.phpため

<?php 

include('init.inc.php'); 

if(isset($POST['name'], $_FILES['files'])){ 
    mail_file('[email protected]', '[email protected]', 'A File 
Upload', '', $_FILES['file']); 
} 
?> 


<html> 
    <head> BACK UP AND SEND 
    <title> BACK UP DATABASE AND SEND TO GMAIL PAGE </title> 
    </head> 
    <body> 
     <br> 
     <br> 
     <img src="gslc.jpg" alt="GSLC" style="width:304px;height:228px;"> 
     <div> 
      <form action = "" method = "post" enctype = "multupart/form- 
data"> 
       <p> 
        <label for="name">Name</label> 
        <input type="text" name="name" id="name" /> 
       </p> 
       <p> 
        <label for="file">File</label> 
        <input type="file" name="file" id="file" /> 
       </p> 
       <p> 
        <input type="submit" value="Email File" /> 
       </p> 
      </form> 
     </div>  
    </body> 
</html> 

コード:mail.inc.phpため

<?php 

$path = dirname(_FILE_); 

include("{$path}/mail.inc.php"); 
?> 

コード:ここ

<?php 

function mail_file($to, $from, $subject, $body, $file){ 
    $boundary = md5(rand()); 

    $headers = array(
     'MIME-Version: 1.0', 
     "Content-Type: multipart/mixed; boundary=\"{boundary}\"", 
     "From: ($from)" 

     ); 

     $message = array(
      "--{$boundary}", 
      "Content-Type: text/plain", 
      "Content-Transfer-Encoding: 7bit" 
      '', 
      chunk_split($body), 
      "--($boundary)" 
      "Content-Type: {$file['type']}; name=\'{$file['name']}\"", 
      "Content-Disposition: attachment; filename=\'{$file['name']}\"", 
      "Content-Transfer-Encoding-base64", 
      '', 

chunk_split(base64_encode(file_get_contents($file['tmp_name']))), 
      "--($boundary)--" 
     ); 

     mail ($to, $subject, implode("\r\n", $message), implode("\r\n", 
$headers)); 
} 

?> 

私の問題PHPファイルを含むコードが間違っているようです。すべてのファイルはhtdocsの下にある "try"フォルダの中にあります。私は既にApacheを実行しています

関連する問題