JavaScript
--
Questions
--
Followers
Top Experts
1. jQuery form - http://jquery.malsup.com/form/
2. jQuerry validation - http://bassistance.de/jquery-plugins/jquery-plugin-validation/
One first link I posted, I am using a file upload being sent via AJAX. I have been reading the docs here:
http://jquery.malsup.com/form/#file-upload
When you fill out the form and hit submit, it just seems like it gets sent, but nothing happens. No page response or info pops up on the Console tab of firebug.
Any ideas?
Thanks,
Ryan
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
And are all the permissions set if necessary?
Permissions are correct. It seems to be a client side issue. On submit does nothing. No PHP errors are returned.
Ian






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
I know if it was js it would need return true at the end to let the form be submitted but anyway back later.
<script type="text/javascript">
$(function() {
jQuery.validator.addMethod("accept", function(value, element, param) {
return value.match(new RegExp("." + param + "$"));
});
$("#apply").validate({
submitHandler: function(form) {
var options = {
success:function(){
$('.sending').hide(function(){$('#apply').hide(function(){$('.success').fadeIn();});});
}
};
$(form).ajaxSubmit(options);
},
iframe: true,
rules: {
email: {
email: true,
required: true
},
confirmemail: {
email: true,
required: true
},
lname:{
required:true
},
fname:{
required:true
},
address:{
required:true
},
city:{
required:true
},
state:{
required:true
},
country:{
required:true
},
mobile_phone:{
required:true
},
other_education:{
required:true
},
job_title:{
required:true
},
job_posting_number:{
required:true
},
hear_job:{
required:true
}/*
,
file: { accept: "(pdf|zip|doc|txt)" }
*/
}
});
});
</script>
So you were able to get the form to submit?
Thanks again!
RYan

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
$path_info = pathinfo($_FILES['file']['name']);
if (!in_array(strtolower($path_info['extension']),array('pdf','zip','doc','txt'))) {
die ("can not upload this type of file");
}
// we'll begin by assigning the To address and message subject
/* $to="higherwork@gmail.com"; */
$to="ryan@ryancoughlin.com";
$subject="New resume for featured job";
// get the sender's name and email address
// we'll just plug them a variable to be used later
$from = stripslashes($_POST['fname'])."<".stripslashes($_POST['email']).">";
// generate a random string to be used as the boundary marker
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
// store the file information to variables for easier access
$tmp_name = $_FILES['resume']['tmp_name'];
$type = $_FILES['file']['type'];
$name = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
$nimi = $_REQUEST['nimi'];
$fname = $_POST["fname"];
$lname = $_POST["lname"];
$address = $_POST["address"];
$city = $_POST["city"];
$state = $_POST["state"];
$country = $_POST["country"];
$email = $_POST["email"];
$home_phone = $_POST["home_phone"];
$mobile_phone = $_POST["mobile_phone"];
$education = $_POST["education"];
$other_education = $_POST["other_education"];
$job_posting_number = $_POST["job_posting_number"];
$hear_job = $_POST["hear_job"];
$job_title = $_POST["job_title"];
// here we'll hard code a text message
// again, in reality, you'll normally get this from the form submission
$message = "A new job application has been submitted. The details are as follows:\n
First Name: $fname\n
Last Name: $lname\n
Address: $address\n
City: $city\n
State: $state\n
Country: $country\n
E-mail: $email\n
Home Phone: $home_phone\n
Mobile Phone: $mobile_phone\n
Education: $education\n
Other Education: $other_education\n
Job Posting Number: $job_posting_number\n
Job Title: $job_title\n
How did you hear about us?: $hear_job\n";
// if the upload succeded, the file will exist
if (file_exists($tmp_name)){
// check to make sure that it is an uploaded file and not a system file
if(is_uploaded_file($tmp_name)){
// open the file for a binary read
$file = fopen($tmp_name,'rb');
// read the file content into a variable
$data = fread($file,filesize($tmp_name));
// close the file
fclose($file);
// now we encode it and split it into acceptable length lines
$data = chunk_split(base64_encode($data));
}
// now we'll build the message headers
$headers .= "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
// next, we'll build the message body
// note that we insert two dashes in front of the
// MIME boundary when we use it
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// now we'll insert a boundary to indicate we're starting the attachment
// we have to specify the content type, file name, and disposition as
// an attachment, then add the file content and set another boundary to
// indicate that the end of the file has been reached
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
$message .="A new job application has been submitted. The details are as follows:
\n\n
First Name: $fname\n
Last Name: $lname\n
Address: $address\n
City: $city\n
State: $state\n
Country: $country\n
E-mail: $email\n
Home Phone: $home_phone\n
Mobile Phone: $mobile_phone\n
Education: $education\n
Other Education: $other_education\n
Job Posting Number: $job_posting_number\n
";
// now we just send the message
if (@mail($to, $subject, $message, $headers))
echo "Submission sent.";
else
echo "Failed to send";
}
}
?>
Ian






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
<a href="#33053070"></a>
Ian
Ryan

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Now with the code it seems like the page is ending, but no action or AJAX call
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><base href="http://www.higherwork.com/">
<title>Higher Work - The World Works When You Do - Apply for Job</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-2" />
<meta name="Keywords" content="Afghanistan jobs, Afghanistan careers, Afghan government jobs, Afghan government positions, International jobs, International careers" />
<link rel="stylesheet" href="css/reset.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="css/text.css" type="text/css" media="screen, projection"/>
<link rel="stylesheet" href="css/960.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen, projection"/>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript">
$(function() {
jQuery.validator.addMethod("accept", function(value, element, param) {
return value.match(new RegExp("." + param + "$"));
});
$("#apply").validate({
submitHandler: function(form) {
var options = {
success:function(){
$('.sending').hide(function(){$('#apply').hide(function(){$('.success').fadeIn();});});
}
};
$(form).ajaxSubmit(options);
},
iframe: true,
rules: {
email: {
email: true,
required: true
},
confirmemail: {
email: true,
required: true
},
lname:{
required:true
},
fname:{
required:true
},
address:{
required:true
},
city:{
required:true
},
state:{
required:true
},
country:{
required:true
},
mobile_phone:{
required:true
},
other_education:{
required:true
},
job_title:{
required:true
},
job_posting_number:{
required:true
},
hear_job:{
required:true
}/*
,
file: { accept: "(pdf|zip|doc|txt)" }
*/
}
});
});
</script>
</head>
<body>
<div class="container_12" id="wrapper">
<div id="header">
<!-- <div id="logo" class="grid_3 push_1">
<a href="index.html"><img src="images/logo.gif" width="199" height="143" alt="Logo" class="logo-shift" /></a>
</div>-->
<div id="logo-text" class="grid_9 push_2">
<img src="images/logo_2010.jpg" />
</div>
</div>
<div class="clear"></div>
<div id="content">
<div class="clear"></div>
</div>
<div id="right-content" class="grid_6">
<strong>
To apply, fill out the form below completely and upload your resume.
</strong><br />
<font color="#FF0000">* <em>Denotes A Required Field</em></font><br /><br />
<form name="apply" id="apply" method="post" action="http://www.ianjgough.com/test/up/upload.php" enctype="multipart/form-data">
<label>Last Name: <font color="#FF0000">*</font></label> <input type="text" size="25" name="lname"/><br />
<label>First Name: <font color="#FF0000">*</font></label> <input type="text" size="25" name="fname" /><br />
<label>Address: <font color="#FF0000">*</font></label> <input type="text" size="25" name="address" /><br />
<label>City: <font color="#FF0000">*</font></label> <input type="text" size="25" name="city" /><br />
<label>State: <font color="#FF0000">*</font></label> <input type="text" size="25" name="state" minlength="2" /><br />
<label>Country: <font color="#FF0000">*</font></label> <input type="text" size="25" name="country" /><br />
<label>E-Mail: <font color="#FF0000">*</font></label> <input type="text" size="25" name="email" /><br />
<label>Confirm E-Mail: <font color="#FF0000">*</font></label> <input type="text" size="25" name="confirmemail" /><br />
<label>Home Telephone: <font color="#FF0000">*</font></label> <input type="text" size="25" name="home_phone" /><br />
<label>Mobile Telephone: <font color="#FF0000">*</font></label> <input type="text" size="25" name="mobile_phone" /><br />
<label>Education Information (indicate highest degree obtained): <font color="#FF0000">*</font></label>
<select name="education">
<option>High School</option>
<option>College</option>
<option>Graduate</option>
<option>Doctorate</option>
<option>High School</option>
</select><br />
<label>Other Education/Specialty Training: <font color="#FF0000">*</font></label> <input type="text" size="25" name="other_education" /><br />
<label>Job Title You Are Applying For: <font color="#FF0000">*</font></label> <input type="text" size="25" name="job_title" /><br />
<label> Job Posting Number (required): <font color="#FF0000">*</font></label> <input type="text" size="25" name="job_posting_number" /><br />
<label>How Did You Hear About This Job (please be detailed): <font color="#FF0000">*</font></label> <textarea name="hear_job"></textarea><br />
<label>Your Resume: <font color="#FF0000">*</font></label> <input type="file" size="25" name="resume" /><br />
<input type="submit" name="submitForm" value="Apply for job" /><br />
</form>
<div class="clear"></div>
<div class="success">
<p>Thank you for submitting your application to HigherWork. Your application will be reviewed and you will be contacted if you are selected to go to the next steps. Please note that HigherWork provides outreach services in order to make information about job opportunities widely available to potential applicants. HigherWork does not make hiring decisions.</p>
</div>
</div>
<div>
<div id="footer" class="grid_12">
<p>You are now applying for the featured posting. To head home click <a href="index.html" title="Home">here</a>.</p>
<p>Copyright HigherWork 2009-10</p>
</div>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-12421850-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
$path_info = pathinfo($_FILES['file']['name']);
if (!in_array(strtolower($path_info['extension']),array('pdf','zip','doc','txt'))) {
die ("can not upload this type of file");
}
// we'll begin by assigning the To address and message subject
/* $to="higherwork@gmail.com"; */
$to="ryan@ryancoughlin.com";
$subject="New resume for featured job";
// get the sender's name and email address
// we'll just plug them a variable to be used later
$from = stripslashes($_POST['fname'])."<".stripslashes($_POST['email']).">";
// generate a random string to be used as the boundary marker
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
// store the file information to variables for easier access
$tmp_name = $_FILES['file']['tmp_name'];
$type = $_FILES['file']['type'];
$name = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
$nimi = $_REQUEST['nimi'];
$fname = $_POST["fname"];
$lname = $_POST["lname"];
$address = $_POST["address"];
$city = $_POST["city"];
$state = $_POST["state"];
$country = $_POST["country"];
$email = $_POST["email"];
$home_phone = $_POST["home_phone"];
$mobile_phone = $_POST["mobile_phone"];
$education = $_POST["education"];
$other_education = $_POST["other_education"];
$job_posting_number = $_POST["job_posting_number"];
$hear_job = $_POST["hear_job"];
$job_title = $_POST["job_title"];
// here we'll hard code a text message
// again, in reality, you'll normally get this from the form submission
$message = "A new job application has been submitted. The details are as follows:\n
First Name: $fname\n
Last Name: $lname\n
Address: $address\n
City: $city\n
State: $state\n
Country: $country\n
E-mail: $email\n
Home Phone: $home_phone\n
Mobile Phone: $mobile_phone\n
Education: $education\n
Other Education: $other_education\n
Job Posting Number: $job_posting_number\n
Job Title: $job_title\n
How did you hear about us?: $hear_job\n";
// if the upload succeded, the file will exist
if (file_exists($tmp_name)){
// check to make sure that it is an uploaded file and not a system file
if(is_uploaded_file($tmp_name)){
// open the file for a binary read
$file = fopen($tmp_name,'rb');
// read the file content into a variable
$data = fread($file,filesize($tmp_name));
// close the file
fclose($file);
// now we encode it and split it into acceptable length lines
$data = chunk_split(base64_encode($data));
}
// now we'll build the message headers
$headers .= "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
// next, we'll build the message body
// note that we insert two dashes in front of the
// MIME boundary when we use it
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// now we'll insert a boundary to indicate we're starting the attachment
// we have to specify the content type, file name, and disposition as
// an attachment, then add the file content and set another boundary to
// indicate that the end of the file has been reached
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
$message .="A new job application has been submitted. The details are as follows:
\n\n
First Name: $fname\n
Last Name: $lname\n
Address: $address\n
City: $city\n
State: $state\n
Country: $country\n
E-mail: $email\n
Home Phone: $home_phone\n
Mobile Phone: $mobile_phone\n
Education: $education\n
Other Education: $other_education\n
Job Posting Number: $job_posting_number\n
";
// now we just send the message
if (@mail($to, $subject, $message, $headers))
echo "Submission sent.";
else
echo "Failed to send";
}
}
?>






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
$path_info = pathinfo($_FILES['resume']['name']);
if (!in_array(strtolower($path_info['extension']),array('pdf','zip','doc','txt'))) {
die ("can not upload this type of file");
}
// we'll begin by assigning the To address and message subject
/* $to="xxxx@gmail.com"; */
$to="xxxxx@aol.com";
$subject="New resume for featured job";
// get the sender's name and email address
// we'll just plug them a variable to be used later
$from = stripslashes($_POST['fname'])."<".stripslashes($_POST['email']).">";
// generate a random string to be used as the boundary marker
$mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
// store the file information to variables for easier access
$tmp_name = $_FILES['resume']['tmp_name'];
$type = $_FILES['file']['type'];
$name = $_FILES['file']['name'];
$size = $_FILES['file']['size'];
$nimi = $_REQUEST['nimi'];
$fname = $_POST["fname"];
$lname = $_POST["lname"];
$address = $_POST["address"];
$city = $_POST["city"];
$state = $_POST["state"];
$country = $_POST["country"];
$email = $_POST["email"];
$home_phone = $_POST["home_phone"];
$mobile_phone = $_POST["mobile_phone"];
$education = $_POST["education"];
$other_education = $_POST["other_education"];
$job_posting_number = $_POST["job_posting_number"];
$hear_job = $_POST["hear_job"];
$job_title = $_POST["job_title"];
// here we'll hard code a text message
// again, in reality, you'll normally get this from the form submission
$message = "A new job application has been submitted. The details are as follows:\n
First Name: $fname\n
Last Name: $lname\n
Address: $address\n
City: $city\n
State: $state\n
Country: $country\n
E-mail: $email\n
Home Phone: $home_phone\n
Mobile Phone: $mobile_phone\n
Education: $education\n
Other Education: $other_education\n
Job Posting Number: $job_posting_number\n
Job Title: $job_title\n
How did you hear about us?: $hear_job\n";
// if the upload succeded, the file will exist
if (file_exists($tmp_name)){
// check to make sure that it is an uploaded file and not a system file
if(is_uploaded_file($tmp_name)){
// open the file for a binary read
$file = fopen($tmp_name,'rb');
// read the file content into a variable
$data = fread($file,filesize($tmp_name));
// close the file
fclose($file);
// now we encode it and split it into acceptable length lines
$data = chunk_split(base64_encode($data));
}
// now we'll build the message headers
$headers .= "From: $from\r\n" .
"MIME-Version: 1.0\r\n" .
"Content-Type: multipart/mixed;\r\n" .
" boundary=\"{$mime_boundary}\"";
// next, we'll build the message body
// note that we insert two dashes in front of the
// MIME boundary when we use it
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message . "\n\n";
// now we'll insert a boundary to indicate we're starting the attachment
// we have to specify the content type, file name, and disposition as
// an attachment, then add the file content and set another boundary to
// indicate that the end of the file has been reached
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$type};\n" .
" name=\"{$name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
$message .="A new job application has been submitted. The details are as follows:
\n\n
First Name: $fname\n
Last Name: $lname\n
Address: $address\n
City: $city\n
State: $state\n
Country: $country\n
E-mail: $email\n
Home Phone: $home_phone\n
Mobile Phone: $mobile_phone\n
Education: $education\n
Other Education: $other_education\n
Job Posting Number: $job_posting_number\n
";
// now we just send the message
if (@mail($to, $subject, $message, $headers))
echo "Submission sent.";
else
echo "Failed to send";
}
}
?>
Didnt mean to close that that soon! But when i get an attachment. It just adds it to the email. Not as a downloadable attachment. Any ideas? on why it is doing that?
Ryan

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
I had this line for client side file ext checking:
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β }/*
,
Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β file: { accept: "(pdf|zip|doc|txt)" }
*/
But that is commented out. In the PHP it allows for PDF.
Ryan






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
JavaScript
--
Questions
--
Followers
Top Experts
JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.