I have a form that emails the results with each submit via a PHP script.
I'm using an ajax script to upload files to my server in the form.
Is it possible to notify me with a YEs or NO if a file has been uploaded?
Is there any waY to attach the file to the form?
Any illustrations?
I'm using ajax and jquery.
Erik
<?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;\"> </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;\"> </span>\n"
."</body></html>\n";
// Mail 1
// multiple recipients $To = 'LOGIC Estimating Team ';
// subject $Subject = 'Logic Pakaging Fast Quote';
// To send HTML mail, the Content-type header must be set $Headers = 'MIME-Version: 1.0' . "\r\n"; $Headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers $Headers .= 'From: LOGIC Estimating Team ' . "\r\n"; $Headers .= 'Cc:' . "\r\n"; $Headers .= 'Bcc:' . "\r\n";
// Mail it mail($To, $Subject, $Body, $Headers);
// Mail 2
$Body = "\n" ." \n" ."\n" ."
\n" ."We received your quote request successfully.\n" ." \n" ."\n" ."Quote ID:".$QuoteID."\n" ."Name:".$Name."\n" ."Company:".$Company."\n" ."Telephone:".$Telephone."\n" ."Email:".$Email."\n" ."\n" ." \n" ."\n";// multiple recipients $To = $Email;
// subject $Subject = 'Logic Pakaging Fast Quote';
// To send HTML mail, the Content-type header must be set $Headers = 'MIME-Version: 1.0' . "\r\n"; $Headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers $Headers .= 'From: LOGIC Estimating Team ' . "\r\n"; $Headers .= 'Cc:' . "\r\n"; $Headers .= 'Bcc:' . "\r\n";
// Mail it mail($To, $Subject, $Body, $Headers);
header("Location: http://www.logicpkg.com/quote_confirm.php?Name=" . urlencode($Name)); ?>
Hard to say without seeing the code or knowing the system. But I assume the ajax uploading, and the form posting which sends the email, are separated. So one really has no idea what happened with the other.
What you could do, is give the file a dynamically generated key, so its name will be something like /uploads/abc123_thefile.zip
. Then on the form that gets posted you'll have an id field, which will be the same as what was tacked onto the file name:
<input type=hidden name=key value='abc123'>
Then when you get the $_POST data, in your php script, you could check the uploads directory for a file that starts with the $_POST['key']
data. You can say yes or no, depending on if that file exists. And you can also attach something to the email, but that's beyond the scope here. Search on stack overflow for php mail mime attachment or something of that nature.
Also, you could store that key in a database or session, upon completion of the ajax upload script, and check for that instead of tacking it onto the file name. There are lots of ways to accomplish this.
That's hard to answer without being more specific and/or posting your code. I mean, it is certainly possible for your uploader script to either signal (say, via a session) or store (say, via a database) an indicator that a file was uploaded, and your email script can do something (like attaching the file) with that information. You can also attach files to emails (I'm assuming that's what you meant) as MIME attachments. Google 'MIME_mail'.
If I didn't answer your question, please describe the desired outcome in more detail.
精彩评论