1

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

1
  • Can you post peace of code, if you use uploadify, can you post your action(controller) where you get files, and js part. I recommend you use Jquery file upload Commented Nov 6, 2012 at 20:02

3 Answers 3

1

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 :-)

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0
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?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.