-1

can i upload a file(image) without submitting the form..

Basically i want to create a webpage where a user can upload an image and preview it side by side but this should not submit my form.

i dont wanna use jquery

2
  • 1
    Why is this tagged java? Commented Dec 9, 2010 at 9:35
  • bcoz m using java and jsp to do this ;) Commented Dec 9, 2010 at 9:44

4 Answers 4

3

You can have two forms on the page. One to upload the image and other one for something else. Just don't nest them.

Sign up to request clarification or add additional context in comments.

2 Comments

good idea will try implementing this... will get back soon :)
But this idea will refresh the page unless you use iframe
1

I've tried to implement this with AJAX but, if it's even possible, it would be a nasty hack. About the best you can do reasonably is to put the file upload form in an iframe, and after posting the file with AJAX, redraw the page with the image.

Comments

0

I think this is what you want But it uses PHP for sever side you can use what ever you want!

Ajax Upload !

All you have to do is create a page which will handle the ajax call, which is saving the image and returning string "true" in case of succeeds. and for Java this (Handling Form-based File Upload with Java Servlet or JSP) should help you.

Check this one out ioncannon.net

8 Comments

the demo on side is not working but i have download it and its working fine and shine.
i dont know anything about PHP, do we need any server for that and how to setup it to test, i want server side language to be java...
@omeid :i knw how to upload.. but the thing is i dont want one extra page(jsp) to be processed.. and it should be dynamic the way it is in gmail... when we attach an attachment it starts uploading it.. i want something of that sort..
You extra page will not be visible to user and will work on background with AJAX. you will have some JavaScript with JQuery on your page and it will send file to the page on server and will show response based on your code.
Get the code from here webdeveloperplus.com/jquery/… and yes it can be done with java as well.
|
0

You can try this .Also check

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.