我正在使用一个 PHP 邮件程序,其中将使用HTML
浏览按钮选择模板以获取数据以发送邮件。
我想在变量中获取数据..无法获取数据..
Warning: fopen(filename.txt) [function.fopen]: failed to open stream: No such file or directory in PATH/php_mailer\sendmail.php on line 18
Cannot open file: filename.txt
HTML
<form name="addtemplate" id="addtemplate" method='POST'
action='' enctype="multipart/form-data">
<table style="padding-left:100px;width:100%" border="0" cellspacing="10" cellpadding="0" id='addtemplate'>
<span id='errfrmMsg'></span>
<tbody>
<tr>
<td class="field_text">
Select Template
</td>
<td>
<input name="template_file" type="file" class="template_file" id="template_file" required>
</td>
</tr>
<tr>
<td>
<input id="group_submit" value="Submit" type="submit" name='group_submit' />
</td>
</tr>
</tbody>
</table>
</form>
PHP 代码
if(isset($_POST['group_submit'])){
if ($_FILES["template_file"]["error"] > 0) {
echo "Error: " . $_FILES["template_file"]["error"] . "<br>";
}
else {
echo $templFile = $_FILES["template_file"]["name"] ;
$templFileHandler = fopen($templFile, 'r') or die('Cannot open file: '.$templFile); //open file for writing ('w','r','a')...
echo $templFileData = fread($templFileHandler,filesize($templFile));
}
}