I have no clue why this isnt working. I have read and read, then done alot of Trial and Error and I cannot seem to get it.
Basically I am trying to send a quote with 5 product images that I attach via the form. all is good but the images are not being sent.
If anyone can tell me what I am missing or doing wrong I would greatly appreciate it.
HTML
[code]
<label for="quote">Quote #: </label>
<input type="text" id="quote" name="quote" /><br/>
<label for="item">Item: </label>
<input type="text" id="item" name="item" /><br/>
<label for="inventory">Inventory: </label>
<input type="text" id="inventory" name="inventory" /><br/>
<label for="category">Category: </label>
<input type="text" id="category" name="category" /><br/>
<label for="manu">Manufacturer: </label>
<input type="text" id="manu" name="manu" /><br/>
<label for="model">Model: </label>
<input type="text" id="model" name="model" /><br />
Condition:
<label for="dimension">Dimension: </label>
<input type="text" id="dimension" name="dimension" /><br />
<label for="desc">Description: </label>
<textarea id="desc" name="desc"></textarea><br/>
<label for="img1">Image 1:</label>
Image 2:
Image 3:
Image 4:
Image 5:
<label for="skidprice">Skid Price: </label>
<input type="text" id="skidprice" name="skidprice" /><br/>
Unit Price:
<label for="totalprice">Total Price: </label>
<input type="text" id="totalprice" name="totalprice" /><br/>
<input name="submit" type="submit" class="submit-button" value="Submit" />
[/code]
PHP
[php]<?php
$email = $_POST ['email'];
$quote = $_POST ['quote'];
$item = $_POST ['item'];
$inventory = $_POST ['inventory'];
$category = $_POST ['category'];
$manu = $_POST ['manu'];
$model = $_POST ['model'];
$condition = $_POST ['condition'];
$dimension = $_POST ['dimension'];
$desc = $_POST ['desc'];
$skidprice = $_POST ['skidprice'];
$unitprice = $_POST ['unitprice'];
$totalprice = $_POST ['totalprice'];
$img1 = $_FILE ['img1'];
$img2 = $_FILE ['img2'];
$img3 = $_FILE ['img3'];
$img4 = $_FILE ['img4'];
$img5 = $_FILE ['img5'];
function imgReisize($uploadedfile, $Destination, $Thumb){
//this is the function that will resize and copy our images
// Create an Image from it so we can do the resize
$src = imagecreatefromjpeg($uploadedfile);
// Capture the original size of the uploaded image
list($width,$height)=getimagesize($uploadedfile);
// For our purposes, I have resized the image to be
// 150 pixels high, and maintain the original aspect
// ratio. This prevents the image from being “stretched”
// or “squashed”. If you prefer some max height other than
// 150, simply change the $newheight variable
$newheight=150;
$newwidth=($width/$height)*150;
$tmp=imagecreatetruecolor($newwidth,$newheight);
// this line actually does the image resizing, copying from the original
// image into the $tmp image
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
// now write the resized image to disk. I have assumed that you want the
// resized, uploaded image file to reside in the ./images subdirectory.
$filename = $Thumb;
imagejpeg($tmp,$filename,100);
imagedestroy($src);
imagedestroy($tmp); // NOTE: PHP will clean up the temp file it created when the request
// has completed.
echo "Successfully Uploaded: ";
}
if(isset($_POST[submit])){
$imgNumb=1; //This the "pointer" to images
$DestinationDir="./quote/images/"; //Place the destination dir here
$ThumbDir="./quote/images/thumbs/"; //Place the thumb dir here
while($_FILES["img".$imgNumb][tmp_name]){
$Unique=microtime(); // We want unique names, right?
$destination=$DestinationDir.md5($Unique).".jpg";
$thumb=$ThumbDir.md5($Unique).".jpg";
imgReisize($_FILES["img".$imgNumb][tmp_name], $destination, $thumb);
$imgNumb++;
}
}
foreach ($_FILES[“img”][“error”] as $key => $error)
{
$tmp_name = $_FILES[“img”][“tmp_name”][$key];
if (!$tmp_name) continue;
$name = basename($_FILES["img"]["name"][$key]);
if ($error == UPLOAD_ERR_OK)
{
if ( move_uploaded_file($tmp_name, "/tmp/".$name) )
$uploaded_array[] .= "Uploaded file '".$name."'.<br/>\n";
else
$errormsg .= "Could not move uploaded file '".$tmp_name."' to '".$name."'<br/>\n";
}
else $errormsg .= "Upload error. [".$error."] on file '".$name."'<br/>\n";
}
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
// More headers
$headers .= 'From: All Food Equipment<[email protected]>' . "\r\n";
$headers .= "Message-ID: <".$now." sales@".$_SERVER['SERVER_NAME'].">\r\n";
$headers .= "X-Mailer: PHP v".phpversion()."\r\n";
$subject = "Your All Food Equip Quote";
$msg =
"
<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">
Your All Food Equipment Quote:
Quote #:......................................................... | $quote |
Item:.............................................................. | $item |
Inventory:....................................................... | $inventory |
Category:....................................................... | $category |
Manufacturer:................................................. | $manu |
Model:........................................................... | $model |
Condition:...................................................... | $condition |
Dimension:.................................................... | $dimension |
Description:................................................... | $desc |
Skid Price:................................................. | $skidprice |
Unit Price:................................................. | $unitprice |
Total Price:................................................ | $totalprice |
How to contact us:
- Visit us Online: www.allfoodequip.com
- Contact: Dino Roberts
- Direct Line: 615-788-2953
- Email: [email protected]
- All Food Equipment
- 1240 Industrial Park Road
- Columbia, TN 38401
- Main Office: 931-490-1977
// MAIL SUBJECT
$subject = "Your All Food Equip Quote";
// TO MAIL ADDRESS
$to="$email";
mail($to, $subject, $msg, $headers);
// Redirect
header(“Location: Admin.php?Msg=Sent”);
?>[/php]