0

I am out of Ideas. The way the system is built I am not sure I can do what I have to do.

This is the controller that processes the uploaded file coming from uploadify.

public ActionResult Upload(HttpPostedFileBase FileData, FormCollection form)
{
     try 
     {
        String path = String.Format("{0}{1}", caminhoArmazenamento, tipoDocNome);

        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
            FileData.SaveAs(path);
            //HERE I NEED SOME CONTROL TO RETURN THAT THINGS WENT RIGHT
        }
        else
        {
            FileData.SaveAs(path);
            //HERE I NEED SOME CONTROL TO RETURN THAT THINGS WENT RIGHT
        }
    }
    catch(exception)
    {
       //HERE I NEED SOME CONTROL SAYING THAT THINGS WENT WRONG
    }
}

This is the uploadify:

$('#file_upload').uploadify({
        'swf': '../../Components/uploadify/uploadify.swf',
        'uploader': '/Operacao/Upload',
        'auto': false,
        'buttonImage': '../../Images/uploadify/importar.jpg',
        'buttonClass': 'uploadifyBtn',
        'width': '250',
        'height': '25',
        'onFallback': function () {
            alert('Versão do flash não compativel com o sistema de upload. Favor contactar o administrador do sistema!');
        },
        'onUploadError' : function(file, errorCode, errorMsg, errorString) {
            alert('O arquivo ' + file.name + ' não pode ser importado: ' + errorCode + ' - ' + errorMsg + ' - ' + errorString);
        },
        'onSelectError': function () {
            alert('Você não tem permissão para acessar o arquivo: "' + file.name + '" ou o arquivo está corrompido. Favor contactar o administrador do sistema.');
        }
    });

Does anybody have sucessfully implement uploadfy in asp net mvc 4? Does not matter what I set as return, I only get a or a general error or an success mensagem. I need to implement error control more specific, for example if a directory could not be created or the file could not be uploaded and why. Thanks

1 Answer 1

1

From what I can tell, depending on the return server code, uploadify will execute different callbacks.

Here is an example of the server returning a 404 and how uploadify response: http://www.uploadify.com/documentation/uploadify/onuploaderror/

What you'll want to do is return the appropriate Response.StatusCode (200, 404, 501) depending on what happens.

How to get MVC action to return 404

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

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.