1

I'm working with ASP.NET(C#) and using CKEditor. When the site is published on the production server, i've noticed the following problem:

  • When i try to upload some images (But not every one of them) with the extesion ".jpg" the CKEditor crashes and shows the followiong message: "The server closed the connection without sending any data."

Below fallows the sample of the code that i'm using:

private ArquivoDTO GetDadosArquivoPostado()
    {
        ArquivoDTO arquivoPostado = null;
        HttpPostedFile arquivoUpload = null;

        // Valida a upload do arquivo
        if ((Request.Files["upload"] == null) || !(Request.Files["upload"] is HttpPostedFile))
        {
            LogElmah.saveLog("Retorno do Upload está vazio (null).", GSUser.Id, null, null);
            return null;
        }

        // Recupera os dados do arquivo de upload
        arquivoUpload = (HttpPostedFile)Request.Files["upload"];

        // Valida dados do arquivo
        if ((string.IsNullOrEmpty(arquivoUpload.FileName)) && (arquivoUpload.InputStream == null))
        {
            LogElmah.saveLog("Dados do arquivo de upload inválidos!", GSUser.Id, null, null);
            return null;
        }

        // Gera os dados do arquivo postado
        arquivoPostado = new ArquivoDTO()
        {
            Nome = string.Format("{0}-{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), Guid.NewGuid().ToString()),
            Extensao = new FileInfo(arquivoUpload.FileName).Extension.Replace(".", ""),
            Caminho = ConfigurationManager.AppSettings["CKEditorCaminhoImagem"],
            FileStream = arquivoUpload.InputStream,
        };

        return arquivoPostado;
    }

Anyone else had this problem before?

Some points that i verified:

  • Web.config" upload configurations.
  • Export the same image again using Photoshop with the option "Save for the Web". When i do this the upload works, but not every one that uses the site has the Photoshop.

Obs: When i try to upload the same image on the local server it works fine, the problem just happens when the site is published and in a production server. Dou you guys have any guess on what could be the problem?

Thanks! Ricardo

Ricardo
  • 11
  • 1
  • Have you verified that it is only a problem w/ ckeditor? Is there a chance that your deployed server is not allowing jpgs (This seems unlikely, but so does the error you're getting). Can you try uploading w/ a normal file upload control and see if jpgs are allowed? – Rikon Apr 02 '14 at 12:46
  • I tried here with a normal file upload control and i got the same error, it seems that is not a CKEditor problem. Do you know if this can be an IIS configuration problem? – Ricardo Apr 02 '14 at 13:19
  • Yeah, there is a white list of acceptable file extensions, though honestly I thought jpg was on that list by default. But try checking IIS: http://www.iis.net/configreference/system.webserver/security/requestfiltering/fileextensions – Rikon Apr 02 '14 at 13:26
  • This is pretty interesting too though, not entirely what you're looking for: http://stackoverflow.com/questions/11905561/how-to-restrict-validate-file-upload-filetypes-server-side-on-iis – Rikon Apr 02 '14 at 13:28

0 Answers0