0

I am working on a php form submit. the form is in a html file and method is submit.php. the fields are-
1. name (text)
2. phone (text)
3. email (test)
4. cv (file)
5. comment (textarea)

I am using jquery form validation plugin (bassistance.de), and jQuery Form Plugin (jquery.malsup.com/form). I want the form to submitted with ajax and email to an address. I have done it successfully. but problem is for file. I cannot understand the procedure. is the file has to be uploaded to server first and then send as attachment? or it can send the file as attachment from client's pc? I am really confused about this. Please help me about this. Also if the file has to be uploaded, then an example for ajax upload will be very helpful. I cannot upload the file when ajax submit the form.

1
  • So the process is - viewers see the form, complete it, choose a file from pc for attachment and send it. the php file will send email with attachment. uploading is not needed. can you give an example please?
    – Imrul.H
    Feb 9, 2012 at 7:13

2 Answers 2

1

You have to let users to upload the file and then attach it to the email.

  1. name (text)
  2. phone (text)
  3. email (test)
  4. cv (file)
  5. comment (textarea)

Once user submit the form you you have to get the file (CV) Please note that default AJAX POST does not support file. So you have to use some kind of hidden iframe POST technique since you are uploading file as well. Once the file uploaded to the server. You can attach it to your mail and send it via PHP.

There are several jQuery plugins also available for this. You can use those if you prefer plugins.

See http://viralpatel.net/blogs/2008/11/ajax-style-file-uploading-using-hidden-iframe.html

1
  • I have also read about the "hidden iframe post" thing. Can you please give an example to do it??
    – Imrul.H
    Feb 9, 2012 at 7:20
0

Don't reinvent the wheel...

I would upload the file via the uploadify plugin - http://www.uploadify.com/. It's Gmail like and looks very crispy.
While You are uploading the file just disable the submit button or do some validation to prevent the submit without the file.

Below is a diagram how to implement the download:

alt text

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.