views:

947

answers:

1

I am using Symfony 1.2.9 for a project, and I need to use AJAX to do file uplaod. I have not found a way of doing this yet - despite days of googling.

I am using JQuery and prototype as my javascript frameworks.

Can anyone provide an example of how to upload a file using AJAX, in Symfony?

+5  A: 

I don't think AJAX itself (as in XMLHTTPREQUEST) can do multipart posts - so you can't use ajax itself to do this.

You can achieve much the same affect though using either flash, or a hidden iframe. I've used swfupload before now, with symfony.

You should take a look at the sfWidgetFormInputSWFUploadPlugin plugin for an example:

http://www.symfony-project.org/plugins/sfWidgetFormInputSWFUploadPlugin

benlumley
recently valums updated their ajax upload plugin, nowadays could track bytes sent and show feedback to the user, i strongly recommend to give a try http://valums.com/ajax-upload/
markcial
ta - looks interesting
benlumley