小编vle*_*sha的帖子

PHP,Swift-mailer问题

当我点击我的联系页面上的提交按钮,尝试提交使用swift-mailer的表单时,我得到了:

警告:fopen(uploads /)[function.fopen]:无法打开流:/home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php中没有这样的文件或目录131

Fatal error: Uncaught exception 'Swift_IoException' with message 'Unable to open file for reading [uploads/]' in /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php:133

Stack trace: 
#0 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php(77): Swift_ByteStream_FileByteStream->_getReadHandle()
#1 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(660): Swift_ByteStream_FileByteStream->read(8192) 
#2 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(337): Swift_Mime_SimpleMimeEntity->_readStream(Object(Swift_ByteStream_FileByteStream)) 
#3 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(448): Swift_Mime_SimpleMimeEntity->getBody()
#4 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/Mime/SimpleMimeEntity.php(463): Swift_Mime_SimpleMimeEntity->toString()
#5 /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ in /home/polycys2/public_html/html/swift-mailer/lib/classes/Swift/ByteStream/FileByteStream.php on line 133
Run Code Online (Sandbox Code Playgroud)

服务器上存在完整路径,但错误消息显示"没有此类文件或目录".可能是什么问题呢?谢谢大家!祝圣诞快乐!

php swiftmailer

5
推荐指数
1
解决办法
7514
查看次数

使用SwiftMailer和PHP检索附加到电子邮件的文件名

昨天我问了这个问题并得到了建议,并使用了它,但是由于某些原因它没有用。因此,我需要检索用户从HTML表单上载到服务器的文件的名称。我需要将此文件附加到PHP / SwiftMailer发送的电子邮件中。这是我的代码,文件上传部分:

    //File upload

// Where the file is going to be placed 
$target_path = "uploads/";

// Add the original filename to our target path.  
//Result is "uploads/filename.extension" 
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}   

//End of file upload
Run Code Online (Sandbox Code Playgroud)

这是文件附加部分:

//Create the attachment
$attachment = Swift_Attachment::fromPath($_FILES['uploadedfile']['tmp_name']);
Run Code Online (Sandbox Code Playgroud)

为什么不从服务器获取文件?这是错误消息,它似乎正在尝试在错误的目录中查找文件:

警告:fopen(/ tmp / phpHJdw0H)[function.fopen]:无法打开流:/home/myserver/mydomain.com/Hawaii/html/swift-mailer/lib/classes/Swift/ByteStream中没有此类文件或目录/FileByteStream.php行131上的致命错误:/home/myserver/mydomain.com/Hawaii/html/swift-mailer/lib中未捕获的异常'Swift_IoException',消息为'无法打开文件以读取[/ tmp / …

php swiftmailer

4
推荐指数
1
解决办法
3760
查看次数

Textarea验证

除非用户将某些数据输入textarea控件,否则我的脚本不应该提交HTML表单.但是,无论如何都会提交表单,并且不会显示用户的任何消息.谁能看到我做错了什么?

这是我的HTML:

<textarea name="description" id="description" rows = "4" cols = "25">
    <?php echo $description?>
    </textarea>
Run Code Online (Sandbox Code Playgroud)

对于PHP,这不是:

if ($_POST['description'] == "") {
            $errors .= 'Please enter a description of your invention.<br/><br/>';
        }
Run Code Online (Sandbox Code Playgroud)

或这个:

if (empty($_POST['description'])) {
            $errors .= 'Please enter a description of your invention.<br/><br/>';
        }   
Run Code Online (Sandbox Code Playgroud)

工作.

html php

1
推荐指数
1
解决办法
8397
查看次数

Apostroph编码为转义字符

我有一个PHP脚本,它从HTML表单中获取数据并通过SwiftMailer发送给它.当用户在输入字段(textarea)中输入撇号或引号时,电子邮件看起来像这样:

表格输入:丈夫的PLD

收到的电子邮件:丈夫的PLD

表格输入:pld的"小吃""老"

收到的电子邮件:pld \'s \"snack \"\"old \"

我的脚本中有一些验证和卫生:

if ($_POST['form_message'] != "") {
        $form_message = filter_var($_POST['form_message'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES);
        if ($_POST['form_message'] == "") {
            $errors .= 'Please enter a valid comment.<br/><br/>';
        }
    } else {
        $errors .= 'Please enter your comment.<br/>';
    }
Run Code Online (Sandbox Code Playgroud)

这是Swiftmailer部分:

$message->setBody("Here is the information submitted to 
Run Code Online (Sandbox Code Playgroud)

www.polycystic-kidneydisease.com/html/contact_email.php来自$ ip on $ date.\n \n -------------------------- ------ \n \n名称:$ name \n \n电子邮件地址:$ email \n \n主题:$ form_subject \n \n comment:$ form_message");

我如何解决它?谢谢!

html php swiftmailer

1
推荐指数
1
解决办法
1223
查看次数

一些HTML输入字段在PHP验证时被清除,而另一些则没有

这是问题所在.我有PHP和HTML表单的数据验证和卫生代码.当表单上的某些字段留空时,验证代码将执行并打印一条消息.我以为我设计的形式是所有填充字段在那时保留输入数据的方式.但是,它被证明是不一致的.例如,名字和姓氏字段变空,而电话和街道字段仍然具有用户在验证发生之前输入的数据.

这是HTML:

<p>
    <label for="firstname">FIRST NAME*:
    </label>
    <input type="text" name="firstname" id="firstname" value="<?php echo $firstname?>" />
</p>    

<p>
    <label for="lastname">LAST NAME*:
    </label>
    <input type="text" name="lastname" id="lastname" value="<?php echo $lastname?>" />
</p>    

<p>
    <label for="phone">TELEPHONE NUMBER*:
    </label>
    <input type="text" name="phone" id="phone" value="<?php echo $phone?>" />
</p>

    <p>
    <label for="street">STREET ADDRESS*:
    </label>
    <input type="text" name="street" id="street" value="<?php echo $street?>" />
</p>
Run Code Online (Sandbox Code Playgroud)

这是验证脚本:

if ($_POST['firstname'] != "") {
        $_POST['firstname'] = filter_var($_POST['firstname'], FILTER_SANITIZE_STRING);
        if ($_POST['firstname'] == "") {
            $errors .= 'Please enter a valid first …
Run Code Online (Sandbox Code Playgroud)

php xhtml

0
推荐指数
1
解决办法
277
查看次数

标签 统计

php ×5

swiftmailer ×3

html ×2

xhtml ×1