here is the form: http://eleganteditions.com/upload.html
Part one works, the image file uploads correctly in all the specified flavors, file sizes and dimensions.
Part two, not so much. Bare with me, i'm a designer, not a coder, so what i did here is a bit of cutting and pasting to put together something functional and EASY based on the few half-a'd assumptions i'm allowed to make.
Ok now scroll all the way down and have a look at my mail function: yep... right THERE! I have put it there because i thought that might get executed alongside the upload... but when i hit the button the upload works but i get no email. Am i going in the right direction here or am i just weeing in the wind?
Thanks in advance,
- Fabio
<?php
// get posted data into local variables
$EmailTo = "info@fabiobasile.com";
$Subject = "A new file was uploaded!";
$name = Trim(stripslashes($_POST['name']));
$email = Trim(stripslashes($_POST['email']));
$comments = Trim(stripslashes($_POST['comments']));
// prepare email body text
$Body .= "name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "e-mail: ";
$Body .= $email;
$Body .= "\n";
$Body .= "comments: ";
$Body .= $comments;
$Body .= "\n";
// ==============
// Configuration
// ==============
$uploaddir = "../upload";
// Where you want the files to upload to
//Important: Make sure this folders permissions is 0777!
$allowed_ext = "jpg, JPG, jpeg, gif, png, pdf";
// These are the allowed extensions of the files that are uploaded
$max_size = "10485760";
// 50000 is the same as 50kb
$max_height = "6000";
// This is in pixels - Leave this field empty if you don't want to upload images
$max_width = "6000";
// This is in pixels - Leave this field empty if you don't want to upload images
// Check Entension
$extension = pathinfo($_FILES['file']['name']);
$extension = $extension[extension];
$allowed_paths = explode(", ", $allowed_ext);
for($i = 0; $i < count($allowed_paths); $i++) {
if ($allowed_paths[$i] == "$extension") {
$ok = "1";
}
}
// Check File Size
if ($ok == "1") {
if($_FILES['file']['size'] > $max_size)
{
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_ERROR_SIZE\">";
exit;
}
// Check Height & Width
if ($max_width && $max_height) {
list($width, $height, $type, $w) = getimagesize($_FILES['file']['tmp_name']);
if($width > $max_width || $height > $max_height)
{
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_ERROR_DIMENSION\">";
exit;
}
}
// The Upload Part
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
}
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_OK\">";
} else {
print "<meta http-equiv=\"refresh\" content=\"0;URL=../upload_ERROR_EXTENSION\">";
}
?>

New Topic/Question
Reply




MultiQuote







|