2

Hey guys I'm trying to implement file upload on my site without refreshing the page. I don't want something like iFrame is there any other way to do this in ajax? I've tried though (USING Codeigniter & ajax but it outputs "You have not uploaded anything"). I've read certain pages like this one but I couldn't seem to implement it properly. Any suggestions guys? I read almost all suggestions posted here using jquery ajax but they are all not good. I just want pure jquery ajax nothing else.

If its not possible, iframe could do please share some examples. :)

Note: This is only good for one upload at a time. No multiples.

Community
  • 1
  • 1
Peter Wateber
  • 3,824
  • 4
  • 21
  • 26

6 Answers6

4

Instead of reinventing a whole thing from a scratch, I would use one of the file upload components.

  1. Plupload - has UI, integrates nicely with jQuery. Depending on browser can use HTML5, Flash, Silverlight or HTML4
  2. Swfupload
  3. Uploadify
Maksym Kozlenko
  • 10,273
  • 2
  • 66
  • 55
0

there is no AJAX file upload. Its all iFrame behind the curtain when it comes to file upload. The example link you gave does not do any magic but it uses hidden iFrame.

Asdfg
  • 11,362
  • 24
  • 98
  • 175
  • How does facebook do it then? I've seen the code I couldn't find iframe – Peter Wateber Apr 16 '12 at 03:51
  • @peter not sure if Facebook changed but it used java applet at one point. – K Z Apr 16 '12 at 03:52
  • 1
    if it creates hidden iframe at runtime, how do you think you will see it? – Asdfg Apr 16 '12 at 03:53
  • There is HTML5 File API and XHTTP request (a.k.a AJAX) – Maksym Kozlenko Apr 16 '12 at 03:55
  • You are wrong. The XMLHttpRequest Level 2 adds support for the new FormData interface which allows AJAX upload of files. Here is a [reference](https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/FormData?redirectlocale=en-US&redirectslug=XMLHttpRequest%2FFormData). – buuda Sep 18 '12 at 22:18
0

Many Answers can be found here: How can I upload files asynchronously?

This question may be a duplicate to the above

Ref: "There's various ready-made plugins on doing file upload on jquery.

Doing this kind of uploading hacks is not an enjoyable experience, so people enjoy using ready-made solutions.

Here's few: http://www.phpletter.com/Demo/AjaxFileUpload-Demo

http://www.fyneworks.com/jquery/multiple-file-upload

Ajax File Upload Plugin Multiple File Upload Plugin You can search more from jquery's plugin -site."

Community
  • 1
  • 1
Joshua Kissoon
  • 3,269
  • 6
  • 32
  • 58
0

From pure ajax it is not possible, you can use this ajax form plugin and it will be handle all things (create iframe automatically for input type file)

Govind Malviya
  • 13,627
  • 17
  • 68
  • 94
0

I have tried many, many plugins for a project in the past, and I came to the conclusion that I liked none of them. Well, except this one: jQuery-file-upload In my experience this is easily the best plugin out there for handling file upload.

K Z
  • 29,661
  • 8
  • 73
  • 78
-1

According to my knowledge there has to be a server side programming language such as php. Try this out. http://valums.com/ajax-upload/

MiniduM
  • 176
  • 6