I have used a hidden iframe for asynchronous file uploads and its
worked out very well for me.

You've got to set up the form separate of other elements so it can use
its submit event, that is essential, also make sure you have
enctype="multipart/form-data" in the form tag.
Next set the target to the name of your iframe, i usually double name
and id so the form and my JS components reference the same value.
You'll have the make sure that the target of your form's post is to
the server side script you want to accept the file.  The server side
script needs to do the action of file upload but also notify the user
that they have successfully uploaded their image and it is now
available for use, this is where it gets kind of tricky.

You'll have to output some HTML that will use javascript to reference
its parent window and then call a function and sending it a string or
the file name.

<script type='text/javascript'>window.parent.fileUploaded("<?=
$_FILES['myfile']['name']?>")</script>

Its pretty verbose but it will work, it avoids security restrictions,
and allows for smooth asynchronous interface.


On Jul 9, 8:40 am, BeeRich <[EMAIL PROTECTED]> wrote:
> On Jul 9, 8:08 am, Peter De Berdt <[EMAIL PROTECTED]> wrote:
>
>
>
> > First of all, the ActionScript code from SWFUpload is just dead
> > simple, even if you don't know jack about flash, you could understand
> > it and see that there's little room for error. The SWFUpload "kid"
> > has just come up with the idea of wrapping it in a simple piece of
> > code, just like the other "ajax upload" scripts are very simple in
> > nature, but the result of a "eureka" moment.
>
> > And if at some point SWFUpload would not be sufficient for my needs,
> > I can do something that's called refactoring, maybe you should look
> > it up. My code is clean enough so that I can take out the SWFUpload
> > code and replace it with something else if a better solution would
> > pop up, I wouldn't have to change on single line of code in my upload
> > script. What these AJAX upload scripts do, is essentially exactly the
> > same thing as you would get with a normal <input type="file"> field,
> > i.e. streaming a file to a method on your server.
>
> > I might be getting the wrong impression here, but you're making it
> > sound as if outsourcing is a bad thing. In a real business,
> > outsourcing can be a great thing if the cost of the outsourcing is
> > lower than the cost of your own time. One can not know everything
> > that's out there and be great at it.
>
> You are getting the wrong message then.  Outsourced is one thing,
> shareware/freeware code is another.  But referring to your outsourcing
> reference, there are a lot of Indian code factories that cannot offer
> half of what a domestic, on-site developer can offer.  With respect to
> being great, it has to have some serious backing before loads of
> organizations would adopt published code.
>
> > > I was talking about learning and exploring, not implementing
> > > something head first.
>
> > Exactly, I spend a fair amount of my free time reading RSS feeds to
> > be in the loop on what's out there. I like to spend my evenings
> > experimenting and trying to see if a solution would be feasible for
> > the projects I'm working on within my company.
>
> As do I.  If anything, the majority of it is to see what is possible,
> what can be done, and most importantly, to give me the knowledge to be
> able to learn the code behind the features it brings, not to simply
> give me ways to copy someone else's recipe for a soup I want.  I love
> expanding what I'm doing, but not to the point my apps are
> questionable down the road, and dependent upon single author's
> websites that can disappear overnight.  I don't expect that to happen
> to any of the tools I use, and that too is a crapshoot.
>
> And I don't like Flash.  Heh.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to