views:

282

answers:

3

Hi friends,

i am creating mail page for sending mails. I need to attach some file before sending. How could i do this using AJAX. Initially i need to store those files in server and then i have to send the mail. These actions are done with in a single send button.

Please help me.

A: 

I hope you know how do the normal upload. Call the upload/Reading and updating the file when click the button by using the ajax call. You have to send the local system file path as the input and then the response should contain the path in the server or error. Update the attachment link with the response in case there are no errors.

Techmaddy
In case you need a basic Ajax reference, http://techmaddy.blogspot.com/2008/01/for-those-who-feel-ajax-is-diffcult-to.html
Techmaddy
A: 

You should dynamically create a hidden iframe in your DOM and set the target of your upload form to this iframe. dont forget to set form method to POST.

you could do both uploading and message field filling in one go.

you should definitely check ready components doing this for the javascript library of your choice.

miceuz