Multiple files upload in grails - ajax

I am trying to implement a comment mechanism in which a user can post a comment and also upload multiple files with it. I am using a g:formRemote for the comment part but I learned that ajax request does not supports file uploads. SO how do I do this? I found few plugins but they did not work for me as I have to save comments as well and these plugins did not support that. I found a way on internet by using iframes, but I am not sure how to do that. Any help would be very appreciated. Thanks

Try to use jQuery Form plugin, it supports ajax file uploads as well so you don't need to implement this by yourself. It also allows to track upload progress.

Related

Using Javascript to download file in Wicket

I am confused on how to do this.. Currently I am implementing an automatic download using Javascript:
target.appendJavaScript("location.href='"+ "./Access.xls" + "';");
This doesn't work.. What is the proper way to trigger an automatic download and how do I properly set the url? I am not too familiar with Javascript but trying to implement this. The file is in the root of the project.. but it tells me it is not found.
Also, when the user downloads it, I would like to then delete it right away after it is downloaded using Javascript, how can I do this? I am using Javascript because I am calling this file within an ajax method.
Thanks!
The best way to get access to that resource, you should use a ResourceReference as explained here. To get the url of a ResourceReference use:
RequestCycle#urlFor(ResourceReference, PageParameters)
However, I don't understand what you need regarding deletion of the file once downloaded. If your file is contained in the jar/war of your project, I don't believe it can be deleted from inside the web app. You could block access to it once it's downloaded however, if that makes sense. Not sure what you're trying to achieve here.

What is the best way to do ajax file uploads in Rails 3.x

What is the best way to achieve ajax file uploads in Rails. I did alot of research, did some testing with remote forms and searched for some jquery plugins. All the plugins i found seemed outdated and i don't know which one will play nice with rails 3.x. Do you guys have any advice on this topic?
Thanks
AFAIK you'll have to be browser specific at the moment. The various browsers are implementing file APIs that allow javascript to read files from the machine. Previously, there was no real way to achieve AJAX file uploading (I think it was for security reasons, but I'm not sure on all the details). I've implemented drag/drop AJAX file uploading before; I can't remember the exact details, but here are some of the resources I used. If I get a chance, I'll see if I can find my code and how I implemented it.
http://demo.tutorialzine.com/2011/09/html5-file-upload-jquery-php
http://www.skuunk.com/2011/04/reading-ajax-xhr-file-uploads-in.html
http://www.centurion-project.org/articles/html5-multiple-file-upload-with-progress-bar
https://developer.mozilla.org/en/Using_files_from_web_applications (best - Mozilla docs)
The Mozilla docs are very useful and got me most of the way there.

Why use Uploadify?

Could somebody mention the advantages of Uploadify file upload plugin over other options that are availabe e.g. swfupload, fancyupload etc.
Uploadify provides a very good jQuery wrapper around swfobject. If you're using jQuery and want to customise the look and feel of your uploads, its a great component to use.

Looking for ajax multi-upload solution using struts2

Our team is looking to support multiple concurrent uploads in struts2 (i.e. "ajaxy", gmail-style file uploads, with progress bars, that
begin immediately instead of when the user submits the form).
We are wondering if there are any tips or best practices for
implementing this feature. For example, does struts require any
special handling for XHR multipart requests? Also, is it appropriate
to use the FileUploadInterceptor for this sort of thing, or is it
better to roll our own?
We've briefly looked at ajax-file-upload-struts2
but it looks as
though that project is either abandoned or incomplete (if that's wrong
please let me know).
As for the client side, we've looked at swfupload, plupload, and
uploadify. They seem to have their various strengths/weaknesses but
if anyone has a found a solution that they prefer we'd love to hear
it.
Struts2 already provides multiple file uploads functionality and its a good one in its own since its doing all the underlying work for you.i believe doing yourself means again doing the same work.
you can have look at current implementation of multiple file upload implementation and can tweak it as per your requirements
here is official document for the multiple file upload using struts2
Multiple File Uploads

Upload an image using jquery AJAX in .net MVC

I am creating one application in .net MVC, in which I am using jQuery AJAX to post some data to server. The data posting is working fine, but I also need to upload one image along with the data. I have searched on stack over flow for similar question but they are not able to help me. I donot want to use flash to upload file, pure jquery solution will help me.
Using some solution I tried to post to server, but on server side I am not getting file data.
Please can some body tell me how to implement file upload in jQuery ajax?
Thanks
Ashwani
I think you're out of luck if you want ajax like uploading without flash. Due to security limitations javascript can't do all the things required. Off the top of my head i'd say your only other option will be to use an iframe to make it appear as thought it was an ajax post.
Why not use flash though? YUI Uploader is amazingly simple and works great!

Resources