This code does not work properly. The code does execute but i am unable to see where the file should be uploaded to. I checked the default directory referenced by the php.ini file but to no avail.
<?php
$to = "nextphaze@live.com";
$firstname = $_REQUEST['firstname'] ;
$lastname = $_REQUEST['lastname'] ;
$mobile = $_REQUEST['mobile'] ;
$email = $_REQUEST['email'] ;
$address = $_REQUEST['address'] ;
$city = $_REQUEST['city'] ;
$subject = "Student Submission Form From: $firstname";
$state = $_REQUEST['state'] ;
$zip = $_REQUEST['zip'] ;
$collegename = $_REQUEST['collegename'] ;
$collegestate = $_REQUEST['collegestate'] ;
$collegezip = $_REQUEST['collegezip'] ;
$collegestatus = $_REQUEST['collegestatus'] ;
$year = $_REQUEST['year'] ;
$message = $_REQUEST['message'] ;
$upload = $_REQUEST['upload'] ;
$headers = "From: [email]nextphaze@live.com[/email]\r\nReply-to: [email]nextphaze@live.com[/email]";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
$headers .= "From: " . $from . "\r\n";
$body = "From: First Name: $firstname \n\n Last Name: $lastname \n\n Mobile Number: $mobile \n\n Email: $email \n\n Address: $address \n\n City: $city \n\n State: $state \n\n
Zip Code: $zip \n\n College Name: $collegename \n\n College State: $collegestate \n\n College Zip: $collegezip \n\n College Status: $collegestatus \n\n Year Graduated: $year \n\n Comments: $message \n\n File: $upload";
$sent = mail($to, $subject, $body, $headers) ;
if ($sent)
echo "Mail has been successfully sent. We will contact you shortly.";
// ==============
// Configuration
// ==============
$uploaddir = "/file..aslhfld;a/";
// Where you want the files to upload to
//Important: Make sure this folders permissions is 0777!
$allowed_ext = "jpg, gif, png, pdf, psd, txt, bmp, mpeg, pjpeg, jpeg, doc, docx";
// These are the allowed extensions of the files that are uploaded
$max_size = "100000000";
// 50000 is the same as 50kb
$max_height = "13680";
// This is in pixels - Leave this field empty if you don't want to upload images
$max_width = "13680";
// This is in pixels - Leave this field empty if you don't want to upload images
// Check Entension
$filename = ($_FILES['upload']['name']);
$extension = pathinfo($_FILES['upload']['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['upload']['size'] > $max_size)
{
print "File size is too big!";
exit;
}
// The Upload Part
if(is_uploaded_file($_FILES['upload']['name']))
{
move_uploaded_file($_FILES['upload']['name'],$uploaddir.'/$file/'.$_FILES['file']['name']);
}
print "Your file has been uploaded successfully!";
} else {
print "Incorrect file extension!";
}
?>
<p>Please click <a href="../forms/stuform.html">here</a> to return to the home page.</p>
SO I NEED HELP WITH THE ABOVE CODE. EVERYTHING WORKS FINE IN TERMS OF THE EMAIL, I NEED HELP WITH THE UPLOAD PART.
HERE IS THE THING THOUGH, THE FOLLOWING CODE IS PRETTY MUCH THE SAME EXCEPT WITHOUT THE OTHER CODING INVOLVED.
<?php
// ==============
// Configuration
// ==============
$uploaddir = "uploads/";
// Where you want the files to upload to
//Important: Make sure this folders permissions is 0777!
$allowed_ext = "jpg, gif, png, txt, pdf, bmp, psd, mpeg, pjpeg, jpeg, doc, docx";
// These are the allowed extensions of the files that are uploaded
$max_size = "100000000";
// 50000 is the same as 50kb
$max_height = "13680";
// This is in pixels - Leave this field empty if you don't want to upload images
$max_width = "13680";
// 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 "File size is too big!";
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 "File height and/or width are too big!";
exit;
}
}
// The Upload Part
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'uploads'.$_FILES['file']['name']);
}
print "Your file has been uploaded successfully!";
} else {
print "Incorrect file extension!";
}
?>
THE ABOVE CODE WORKS, AND I AM ABLE TO SEE WHERE THE FILE IS BEING UPLOADED AND IT IS NOT REFERENCED AT ALL BY THE DEFAULT IN THE PHP.INI. THE FUNNY THINGS IS THAT THIS PART OF THE CODE IS JUST ABOUT THE SAME AS THE PREVIOUS CODE MENTIONED ABOVE. I AM ASKING FOR DETAILED HELP. PLEASE DO NOT RESPOND IF YOU HAVE NOTHING SPECIFIC TO SAY OR HAVE EXTREMELY VAGUE DIRECTIONS. I NEED HELP WITH THE CODE AS SOON AS POSSIBLE. THANK YOU IN ADVANCE.