How to upload a image file using ajax by using prototype.js plugin, I need to display those image after it is uploaded please help to solve this problem.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You will need something on the server, too.
I recommend using paperclip for storing the files on your server.
Once you have it set up, you should make your ajax generate one form with a “file” field. Also, remember that the form must be multipart.
If you just need to upload one file, you probably don’t need full AJAX – only plain javascript – for showing/hiding the form. Like this:
Notice that for hiding/showing the div I’m using a Scriptaculous effect, not just prototype – scriptaculous gets included by default on rails anyway.