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