Reputation: 11
I want to handle the image uploads with a multi uploader (uploadify or other plugins will do), but I couldn't make it work with symfony.
I tried the swfuploader plugin, but it didn't work, there was an error with javascript.
How can I handle an ajax upload with symfony?
Thanks
Upvotes: 1
Views: 2074
Reputation: 562
public function executeUpload($request){
if($request->isMethod("POST")){
foreach($request->getFiles() as $file){
/* do what you want with $file */
}
}
}
How do you read the content of the file?
Upvotes: 0
Reputation: 6923
It works fine with uploadify on my sites ! But for a more concrete answer you have to supply additional informations on your code.
As a short draft you may take this, please consider about the session_id for symfony security.
jQuery("#myupload").uploadify({
'script' : '<?php echo url_for("model/upload")."?".ini_get("session.name") . "=" . session_id(); ?>',
'scriptData' : { "sf_user_id": '<?php echo $sf_user_id ?>' }
});
public function executeUpload($request){
if($request->isMethod("POST")){
foreach($request->getFiles() as $file){
/* do what you want with $file */
}
}
}
Good luck :-)
Upvotes: 1
Reputation: 1334
Symfony 1.4 had some major changes regarding Javascript, the main helper has changes its name so i think that first you should check compatibility between Plugin and Symfony1.4. Also you could add some plugin that enhaces your Javascript programming like Protoculous.
Upvotes: 0