Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
jQuery file uploading
Old 09-28-2011, 03:12 PM jQuery file uploading
numbenator's Avatar
Webmaster Talker

Posts: 523
Location: London
Trades: 0
Hey all

can someone recommend to me a really simple
jquery file upload plugin or script.

I simply want to upload a file from local and save it to my server.

Cheers

Steve
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
 
Register now for full access!
Old 09-28-2011, 04:05 PM Re: jQuery file uploading
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
What could be simpler than a form with a input type="file" and submit button?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-28-2011, 04:11 PM Re: jQuery file uploading
numbenator's Avatar
Webmaster Talker

Posts: 523
Location: London
Trades: 0
err if you read the question i asked for script to do file upload with jquery.
__________________

Please login or register to view this content. Registration is FREE
numbenator is offline
Reply With Quote
View Public Profile Visit numbenator's homepage!
 
Old 09-28-2011, 05:00 PM Re: jQuery file uploading
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Yes I read that, but as javascript CANNOT actually upload files to a server, you end up messing about with javascript just to do exactly the same thing as a file input and a submit button does, what is the point of adding a layer of complexity for zero gain?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-28-2011, 07:00 PM Re: jQuery file uploading
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
Yep. You'd need to use a form with <input type="file" />. If you were going for something more pretty, however, like the ones with the progress bar, you could look at this for a simple way to do it.
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 09-29-2011, 06:46 PM Re: jQuery file uploading
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
If you're just looking for simplicity, I'd recommend this script, that I used myself for my site. Unfortunately I could not find the link to where I got it, so I'll paste the entire file (which isn't very big anyway ) including credits. Although you could most likely find the source through google.

Like many "AJAX upload scripts" this one simply adds an invisible iframe to where it redirects the submitted form (which contains some file input field(s)), and then grabs the output in the frame as the response. But unlike many other such scripts, it does only that and nothing more. So if you i.e. want json formatted result you have to parse it yourself (as in my example below).

Heres the script jquery.iframe-post-form.min.js
Code:
/**
 * jQuery plugin for posting form including file inputs.
 * Copyright (c) 2010 Ewen Elder
 *
 * Licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * @author: Ewen Elder <glomainn at yahoo dot co dot uk> <ewen at jainaewen dot com>
 * @version: 1.0.1 (2010-22-02)
**/
(function($){$.fn.iframePostForm=function(o){var J,a,i,n;a=$(this);o=$.extend({},$.fn.iframePostForm.defaults,o);if(!$('#'+o.iframeID).length){$('body').append('<iframe name="'+o.iframeID+'" id="'+o.iframeID+'" style="display:none"></iframe>')}return a.each(function(){i=$(this);i.attr('target',o.iframeID);i.submit(function(){o.post.apply(this);n=$('#'+o.iframeID);n.one('load',function(){J=n.contents().find('body');o.complete.apply(this,[J.html()]);setTimeout(function(){J.html('')},1)})})})};$.fn.iframePostForm.defaults={iframeID:'iframe-post-form',post:function(){},complete:function(response){}}})(jQuery);
And here's an example usage
Code:
$(document).ready(function(){
    $('#upload_form').iframePostForm({
        post : function() {
            // run when form is submitted
        },
        complete : function (response) {
            // run when request is completed
            try {
                json = $.parseJSON(response);
                // do something smart
            } catch (e) {
                // generate some error
            }
        }
    });
});
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Reply     « Reply to jQuery file uploading
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.43768 seconds with 12 queries