1. #1
    Sencha User
    Join Date
    Nov 2011
    Location
    Cuttack,Odisha,India
    Posts
    61
    Vote Rating
    1
    debabrata is on a distinguished road

      0  

    Question Unanswered: How can i get the size of the file before upload ?

    Unanswered: How can i get the size of the file before upload ?


    I want to validate a file before upload using the size of file.
    My code is
    Code:
    Ext.create('Ext.form.Panel', {                title: 'Upload a Photo',
                    width: 400,
                    bodyPadding: 10,
                    frame: true,
                    renderTo: Ext.getBody(),
                    items: [{
                        xtype: 'filefield',
                        name: 'photo',
                        id:'photo',
                        fieldLabel: 'Photo',
                        labelWidth: 50,
                        msgTarget: 'side',
                        allowBlank: false,
                        anchor: '100%',
                        buttonText: 'Select Photo...'
                    }],
    
                    buttons: [{
                        text: 'Upload',
                        handler: function() {
                            var form = this.up('form').getForm();
                            if(form.isValid()){
                                alert(Ext.getCmp('photo').size);
                            }
                        }
                    }]
                });
    But result is always 20.
    Is there any way to get the size of a file ?

  2. #2
    Sencha User
    Join Date
    Jun 2011
    Location
    Russia
    Posts
    34
    Vote Rating
    1
    icemanovich is on a distinguished road

      0  

    Default


    On server side you can see it if execute
    PHP Code:
    print_r($_FILES); 
    structure of $_FILES array will be:
    PHP Code:
    Array ( 
        [
    formName] => Array ( 
            [
    name] => files.sig 
            
    [type] => application/octet-stream 
            
    [tmp_name] => /tmp/phpHdk2fZ 
            
    [error] => 
            
    [size] => 12316 
        



    and then you can validate it like this:
    PHP Code:
    if ($_FILES['formName']['size'] > SomeValue){
        
    //success
    } else {
        
    // error


  3. #3
    Sencha User
    Join Date
    Nov 2011
    Location
    Cuttack,Odisha,India
    Posts
    61
    Vote Rating
    1
    debabrata is on a distinguished road

      0  

    Default


    Thanks icemanovich for your response.But can we check that in extjs 4 ?

  4. #4
    Sencha User
    Join Date
    Jun 2011
    Location
    Russia
    Posts
    34
    Vote Rating
    1
    icemanovich is on a distinguished road

      0  

    Default


    It seems, that in ExtJs it's can't be done. But, another way use ActiveXObject....like this:
    Code:
    function getSize()
    {
        var myFSO = new ActiveXObject("Scripting.FileSystemObject");
        var filepath = document.upload.file.value;
        var thefile = myFSO.getFile(filepath);
        var size = thefile.size;
        alert(size + " bytes");
    }
    But, why you don't use PHP for this task? You can do that: click the button and in php scenario validate file size
    PHP Code:
    $_FILES['formname']['size'
    and then use
    PHP Code:
    move_uploaded_file ($temp_file_name$new_name

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