PHP Form通过电子邮件发送结果。我需要捕获表单中的上传文件

时间:2011-01-15 04:43:04

标签: php jquery upload

我有一个表单,通过PHP脚本通过每次提交通过电子邮件发送结果。

我正在使用ajax脚本将文件上传到我的服务器中。

是否可以通过YE通知我,或者是否已上传文件?

是否有任何问题要将文件附加到表单?

任何插图?

我正在使用ajax和jquery。

埃里克

    <?php
    $prefix = 'LPFQ';
    $uniqid = $prefix . uniqid();
    $QuoteID = strtoupper($uniqid); 
    $Email      = $_REQUEST['Email'];
    $Name       = $_REQUEST['Name'];
    $Company    = $_REQUEST['Company'];
    $Telephone  = $_REQUEST['Telephone'];
    $Message    = stripslashes($_REQUEST['Message']);
    $Industry       = $_REQUEST['Industry'];
    $ProjectName     = stripslashes($_REQUEST['ProjectName']);
    $Combination     = $_REQUEST['Combination'];
    $DateExpectDelivery  = $_REQUEST['DateExpectDelivery'];
    $UploadFiles     = $_REQUEST['UploadFiles'];
    $Quantity1   = $_REQUEST['Quantity1'];
    $Quantity2   = $_REQUEST['Quantity2'];
    $Quantity3   = $_REQUEST['Quantity3'];
    $Quantity4   = $_REQUEST['Quantity4'];
    $CartonSizeLength    = $_REQUEST['CartonSizeLength'];
    $CartonSizeWidth     = $_REQUEST['CartonSizeWidth'];
    $CartonSizeHeight    = $_REQUEST['CartonSizeHeight'];
    $FlatSizeWidth   = $_REQUEST['FlatSizeWidth'];
    $FlatSizeHeight  = $_REQUEST['FlatSizeHeight'];
    $CartonStyle     = $_REQUEST['CartonStyle'];
    $BoardCaliper    = $_REQUEST['BoardCaliper'];
    $BoardDescription    = $_REQUEST['BoardDescription'];
    $ColorsSpot  = $_REQUEST['ColorsSpot'];
    $ColorsProcess   = $_REQUEST['ColorsProcess'];
    $ColorsTotal     = $_REQUEST['ColorsTotal'];
    $CoatFinish  = $_REQUEST['CoatFinish'];
    $CoatFinish2     = $_REQUEST['CoatFinish2'];
    $DieCutHolesNum  = $_REQUEST['DieCutHolesNum'];
    $DieCutHolesStrip    = !empty($_REQUEST['DieCutHolesStrip']) ? 'Yes' :       'No';
    $DieCutHolesPerf     = !empty($_REQUEST['DieCutHolesPerf']) ? 'Yes' : 'No';
    $GlueAreasNum    = $_REQUEST['GlueAreasNum'];
    $GlueAreasCheck  = !empty($_REQUEST['GlueAreasCheck']) ? 'Yes' : 'No';
    $GlueAreasSensor     = !empty($_REQUEST['GlueAreasSensor']) ? 'Yes' : 'No';
    $GlueAreasRFID   = !empty($_REQUEST['GlueAreasRFID']) ? 'Yes' : 'No';
    $WindowPatchWidth    = $_REQUEST['WindowPatchWidth'];
    $WindowPatchHeight   = $_REQUEST['WindowPatchHeight'];
    $SpecialtyFoil   = !empty($_REQUEST['SpecialtyFoil']) ? 'Yes' : 'No';
    $SpecialtyBoss   = !empty($_REQUEST['SpecialtyBoss']) ? 'Yes' : 'No';
    $SpecialtyBraille    = !empty($_REQUEST['SpecialtyBraille']) ? 'Yes' : 'No';
    $SpecialtyInserts    = !empty($_REQUEST['SpecialtyInserts']) ? 'Yes' : 'No';
    $ShipToZip   = $_REQUEST['ShipToZip'];
    $InnerDivider    = !empty($_REQUEST['InnerDivider']) ? 'Yes' : 'No';        

    $MyTimezone = date_default_timezone_set('America/Los_Angeles');

$ Body =“\ n”                                 。“\ n”                                 “\ n”                                 “
\ n” 个

                                ."<span style=\"line-height:10px;\">&nbsp;</span>\n"
                                ."<table id=\"hor-zebra\">\n"
                                ."<tr><td class=\"label\"><strong>Quote ID:</strong></td><td>".$QuoteID."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Name:</strong></td><td>".$Name."</td></tr>\n"
                                ."<tr><td><strong>Company:</strong></td><td>".$Company."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Telephone:</strong></td><td>".$Telephone."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Email:</strong></td><td>".$Email."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Industry:</strong></td><td>".$Industry."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Combination:</strong></td><td>".$Combination."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Additional Notes:</strong></td><td>".$Message."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Upload Files:</strong></td><td>".$UploadFiles."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Project Name:</strong></td><td>".$ProjectName."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Quantity 1:</strong></td><td>".$Quantity1."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Quantity 2:</strong></td><td>".$Quantity2."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Quantity 3:</strong></td><td>".$Quantity3."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Quantity 4:</strong></td><td>".$Quantity4."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Carton Size Length:</strong></td><td>".$CartonSizeLength."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Carton Size Width:</strong></td><td>".$CartonSizeWidth."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Carton Size Height:</strong></td><td>".$CartonSizeHeight."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Flat Size Width:</strong></td><td>".$FlatSizeWidth."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Flat Size Height:</strong></td><td>".$FlatSizeHeight."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Carton Style:</strong></td><td>".$CartonStyle."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Inner Divider:</strong></td><td>".$InnerDivider."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Board Caliper:</strong></td><td>".$BoardCaliper."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Board Description:</strong></td><td>".$BoardDescription."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Colors Spot:</strong></td><td>".$ColorsSpot."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Colors Process:</strong></td><td>".$ColorsProcess."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Colors Total:</strong></td><td>".$ColorsTotal."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Coat Finish:</strong></td><td>".$CoatFinish."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Coat Finish 2:</strong></td><td>".$CoatFinish2."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Die Cut Holes Num:</strong></td><td>".$DieCutHolesNum."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Die Cut Holes Strip:</strong></td><td>".$DieCutHolesStrip."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Die Cut Holes Perf:</strong></td><td>".$DieCutHolesPerf."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Glue Areas Num:</strong></td><td>".$GlueAreasNum."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Glue Areas Check:</strong></td><td>".$GlueAreasCheck."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Glue Areas Sensor:</strong></td><td>".$GlueAreasSensor."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Glue Areas RFID:</strong></td><td>".$GlueAreasRFID."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Window Patch Width:</strong></td><td>".$WindowPatchWidth."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Window Patch Height:</strong></td><td>".$WindowPatchHeight."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Specialty Foil:</strong></td><td>".$SpecialtyFoil."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Specialty Boss:</strong></td><td>".$SpecialtyBoss."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Specialty Braille:</strong></td><td>".$SpecialtyBraille."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Specialty Inserts:</strong></td><td>".$SpecialtyInserts."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Ship To Zip:</strong></td><td>".$ShipToZip."</td></tr>\n"
                                ."<tr><td class=\"label\"><strong>Date Expect Delivery:</strong></td><td>".$DateExpectDelivery."</td></tr>\n"
                                ."<tr class=\"odd\"><td class=\"label\"><strong>Date of Submission:</strong></td><td>".date("Y-m-d H:i A e")."</td></tr>\n"
                                ."</table>\n"
                                ."<span style=\"line-height:30px;\">&nbsp;</span>\n"
                                ."</body></html>\n";

//邮件1

//多个收件人 $ To ='LOGIC Estimating Team';

//主题 $ Subject ='Logic Pakaging Fast Quote';

//要发送HTML邮件,必须设置Content-type标头 $ Headers ='MIME-Version:1.0'。为 “\ r \ n” 个; $ Headers。='Content-type:text / html; charset = iso-8859-1'。为 “\ r \ n” 个;

//其他标题 $ Headers。='来自:LOGIC Estimating Team'。为 “\ r \ n” 个; $ Headers。='抄送:'。为 “\ r \ n” 个; $ Headers。='密送:'。为 “\ r \ n” 个;

//邮寄它 邮件($ To,$ Subject,$ Body,$ Headers);

// Mail 2

$ Body =“\ n”                                 。“\ n”                                 “\ n”                                 “
\ n”                                     “我们成功收到了您的报价请求。

\ n”                                     “\ n”                                     “\ n”                                     。“报价ID:”。$ QuoteID。“\ n”                                     “名称:”。$名称 “\ n”                                     。 “的公司”。$公司 “\ n” 个。                                     。 “的电话:”。$电话 “\ n” 个                                     。 “电子邮件:”。$电子邮件 “\ n” 个。                                     “\ n”                                     “\ n”                                     。 “\ n” 个;

//多个收件人 $ To = $ Email;

//主题 $ Subject ='Logic Pakaging Fast Quote';

//要发送HTML邮件,必须设置Content-type标头 $ Headers ='MIME-Version:1.0'。为 “\ r \ n” 个; $ Headers。='Content-type:text / html; charset = iso-8859-1'。为 “\ r \ n” 个;

//其他标题 $ Headers。='来自:LOGIC Estimating Team'。为 “\ r \ n” 个; $ Headers。='抄送:'。为 “\ r \ n” 个; $ Headers。='密送:'。为 “\ r \ n” 个;

//邮寄它 邮件($ To,$ Subject,$ Body,$ Headers);

标题(“位置:http://www.logicpkg.com/quote_confirm.php?Name=”。urlencode($ Name)); ?&GT;

2 个答案:

答案 0 :(得分:0)

如果不更具体和/或发布您的代码,这很难回答。我的意思是,您的上传器脚本当然可以发信号(例如,通过会话)或存储(例如,通过数据库)指示文件已上载,并且您的电子邮件脚本可以执行某些操作(例如附加文件) )有了这些信息。您还可以将文件作为MIME附件附加到电子邮件(我假设这就是您的意思)。谷歌'MIME_mail'。

如果我没有回答你的问题,请更详细地描述所需的结果。

答案 1 :(得分:0)

很难说没有看到代码或了解系统。但我认为ajax上传和发送电子邮件的表单发布是分开的。所以真的不知道对方发生了什么。

您可以做的是为文件提供动态生成的密钥,因此其名称将类似于/uploads/abc123_thefile.zip。然后在发布的表单上,您将拥有一个id字段,该字段与添加到文件名的字段相同:

<input type=hidden name=key value='abc123'>

然后当你获得$ _POST数据时,在php脚本中,你可以检查uploads目录中是否有以$_POST['key']数据开头的文件。您可以说是或否,具体取决于该文件是否存在。您还可以在电子邮件中附加内容,但这超出了此处的范围。搜索堆栈溢出的php邮件mime附件或那种性质的东西。

此外,您可以在完成ajax上载脚本后将该密钥存储在数据库或会话中,并检查该密钥而不是将其添加到文件名中。有很多方法可以实现这一目标。