1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    8
    Vote Rating
    0
    Alexdinu is on a distinguished road

      0  

    Default FileField is empty after submit.

    FileField is empty after submit.


    When I perform a submit, I don't see the fileField properties in the handler. Here is my JS code:


    { xtype: 'container', margin: '5 5 5 5', border: false, frame: false, layout: { type: 'hbox' }, items: [ { xtype: 'form', fileCount: 1, id: 'adpAttachmentFormid', border: false, api: {submit: 'iConnect.Attachments1.saveFile'}, items: [ { xtype: 'filefield', emptyText: 'Click Browse button to add a file', buttonText: 'Browse', width: 300, id: 'fileid', disabledCls: 'disabledControl', listeners: { change: function (file, value) { if (file.value != file.emptyText && file.value != "") { var grid = file.up("form").down("grid"); var store = file.up("form").down("grid").getStore(); //get the store from the grid on the form var form = Ext.ComponentQuery.query('form[id="adpAttachmentFormid"]')[0]; form.submit(); store.add({ objId: store.count() + 1, fileName: file.value, fileLink: file.value, version: 1, additionalInformation: "", attachedBy: "", isForInternalUseOnly: 0 }); grid.show(); file.reset(); } } } }, { id: 'uxadpfileuploadgridid', xtype: 'uxadpfileuploadgrid', hidden: true }] }]And this is the handler code:
    [DirectMethodForm] public JObject saveFile(HttpRequest request) { try { for (int i = 0; i < request.Files.Count; i++) { if (request.Files.Count > 0) { HttpPostedFile file = request.Files[i]; if (file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); BinaryReader b = new BinaryReader(file.InputStream); byte[] binData = b.ReadBytes(file.ContentLength); fileSystemObj.CreateDirectory(temporaryFolderPath); fileSystemObj.ByteArrayToFile(temporaryFolderPath + "\\" + fileName, binData); } } } retMessage = " was successfully uploaded."; } catch (Exception ex) { ADPDS.CustomExceptionHandler.ExceptionHandler.HandleException(ex, "DBLog"); return new JObject( new JProperty("success", false), new JProperty("file", fileName), new JProperty("message", "file failed to be uploaded.")); } return new JObject( new JProperty("success", true), new JProperty("file", fileName), new JProperty("message", "file was successfully uploaded.")); } But file variable above does not contain the properties such as file name and contents.ThanksAlex

  2. #2
    Sencha User
    Join Date
    Aug 2012
    Posts
    8
    Vote Rating
    0
    Alexdinu is on a distinguished road

      0  

    Default Cleaner code

    Cleaner code


    Code:
    {
        xtype: 'container',
        margin: '5 5 5 5',
        border: false,
        frame: false,
        layout: {
            type: 'hbox'
        },
        items: [
        {
            xtype: 'form',
            fileCount: 1,
            id: 'adpAttachmentFormid',
            border: false,
            api: {submit: 'iConnect.Attachments1.saveFile'},
            items: [
            {
                xtype: 'filefield',
                emptyText: 'Click Browse button to add a file',
                buttonText: 'Browse',
                width: 300,
                id: 'fileid',
                disabledCls: 'disabledControl',
                listeners:
                {
    change: function (file, value) {
        if (file.value != file.emptyText && file.value != "") {
            var grid = file.up("form").down("grid");
            var store = file.up("form").down("grid").getStore();  //get the store from the grid on the form
            var form = Ext.ComponentQuery.query('form[id="adpAttachmentFormid"]')[0];
            form.submit();
    
    
            store.add({
                objId: store.count() + 1,
                fileName: file.value,
                fileLink: file.value,
                version: 1,
                additionalInformation: "",
                attachedBy: "",
                isForInternalUseOnly: 0
            });
    
    
            grid.show();
            file.reset();
    
    
        }
    }
                }
            },
            {
                id: 'uxadpfileuploadgridid',
                xtype: 'uxadpfileuploadgrid',
                hidden: true
            }]
        }]
    Code:
    [DirectMethodForm]
    public JObject saveFile(HttpRequest request)
    {
        BaseForm baseFormObj = new BaseForm();
        string retMessage = string.Empty;
        string fileName = string.Empty;
        string focusId = ADPDS.Utility.Utility.DBNullToString(request["ObjectID"]);// case or sub case id.
        string loginName = baseFormObj.UserData.VisionLogin;
        ADPDS.Utility.FileSystem fileSystemObj = new ADPDS.Utility.FileSystem();
        string temporaryFileAttachmentPath = System.Configuration.ConfigurationManager.AppSettings["TemporaryAttachmentsPath"];//TemporaryAttachmentsPath
        string temporaryFolderPath = temporaryFileAttachmentPath + "\\" + loginName + "\\" + focusId;
    
    
        try
        {
    for (int i = 0; i < request.Files.Count; i++)
    {
        if (request.Files.Count > 0)
        {
    HttpPostedFile file = request.Files[i];
    if (file.ContentLength > 0)
    {
        fileName = Path.GetFileName(file.FileName);
        BinaryReader b = new BinaryReader(file.InputStream);
        byte[] binData = b.ReadBytes(file.ContentLength);
    
    
        fileSystemObj.CreateDirectory(temporaryFolderPath);
        fileSystemObj.ByteArrayToFile(temporaryFolderPath + "\\" + fileName, binData);
    }
        }
    }
        retMessage = " was successfully uploaded.";
        }
        catch (Exception ex)
        {
    ADPDS.CustomExceptionHandler.ExceptionHandler.HandleException(ex, "DBLog");
    return new JObject(
       new JProperty("success", false),
       new JProperty("file", fileName),
       new JProperty("message", "file failed to be uploaded."));
    
    
        }
    
    
        return new JObject(
           new JProperty("success", true),
           new JProperty("file", fileName),
           new JProperty("message", "file was successfully uploaded."));
    }

  3. #3
    Sencha - Support Team
    Join Date
    Feb 2013
    Location
    California
    Posts
    3,379
    Vote Rating
    62
    Gary Schlosberg is a jewel in the rough Gary Schlosberg is a jewel in the rough Gary Schlosberg is a jewel in the rough

      0  

    Default


    Are you getting anything helpful from the server response?
    Get on the Fast Track with Sencha Training http://sencha.com/training

    Are you a Sencha products veteran who has wondered what it might be like to work at Sencha? If so, please reach out to our recruiting manager: sheryl@sencha.com

  4. #4
    Sencha User
    Join Date
    Aug 2012
    Posts
    8
    Vote Rating
    0
    Alexdinu is on a distinguished road

      0  

    Default


    Not sure what you mean, but the server does contain the HttpRequest object and since it does not find the HttpPostedFile data, it does not set the KObject to false.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi