-2
我有一個文件夾「嘗試」在htdocs下,我將一個php文件連接到html,但不會包含php文件。我的代碼有什麼問題嗎?如何在html代碼中包含php文件
<?php
include 'init.inc.php';
?>
html和php文件在「try」文件夾中。原諒我,我只是一個新手!
我有一個文件夾「嘗試」在htdocs下,我將一個php文件連接到html,但不會包含php文件。我的代碼有什麼問題嗎?如何在html代碼中包含php文件
<?php
include 'init.inc.php';
?>
html和php文件在「try」文件夾中。原諒我,我只是一個新手!
代碼的index.html:
<?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>
代碼init.inc.php:
<?php
$path = dirname(_FILE_);
include("{$path}/mail.inc.php");
?>
代碼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
服務器上'try'的絕對路徑是什麼? –
你怎麼知道它不被包括在內?是否有錯誤訊息? – Pharaoh
c:/ xampp/htdocs/try –