Jump to content


Photo

pl upload unable to accept big dimension .gif file


  • Please log in to reply
3 replies to this topic

#1 sasori

sasori

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts

Posted 08 September 2013 - 09:03 AM

2 Problems

 

Hi,

 

1 ) 

has anyone ever used the plupload ?, my problem right now is, when i triy uploading .gif files with big dimensions, it doesn't get through.

but with jpeg,jpg it does work

 

here's the current configuration of my plupload

                    'options' => array(
'runtimes' => 'gears,html5,flash,silverlight,browserplus',
                        'url' => $this->createUrl('upload'),
                        "max_file_size" => '10mb',
                        'chunk_size' => '1mb',
                        'unique_names' => true,
                        'resize' => array('width' => 900, 'height' => 900, 'quality' => 90),
                        'filters' => array(
                            array("title" => "Image files", "extensions" => "jpg,gif,png,jpeg")
                        ),

2) how to throw an error to the user that the upload has failed ? , like e.g while uploading the internet connection has failed.

and I wanna tell them that they need to re-upload the file?

 

I added this in the array

 

'Error' => 'js:function(up,file){
alert("File was not uploaded properly");
}',

Edited by sasori, 08 September 2013 - 09:13 AM.


#2 jazzman1

jazzman1

    Advanced Member

  • Gurus
  • 2,453 posts
  • LocationMississauga, Canada

Posted 08 September 2013 - 08:41 PM

Hey sasori,
 
just create a custom function and bind the plupload "FileUploaded" method to it. Check if all files are successfully uploaded on the server and the status of this connection is equal to 200.

Then pass this custom function to preinit.

So, it would like something like:

// added redirect function after uploading was successfully
function attachCallbacks(uploader) {
uploader.bind('FileUploaded', function(Up, File, Response) {
    // count total of uploaded files
    var u_count = uploader.total.uploaded;
    // get the length of uploaded files
    var f_length = uploader.files.length;
    // check the status and status of failed uploaded files
     if(!uploader.total.failed && Response.status == 200) {
      // redirect the page after successfully uploading images
        if((u_count+1) == f_length) window.location.assign('http://www......');
     } else {
     alert('Failed uploading'); return false;
       }
    })
}

All script:

<script type="text/javascript">
      // Convert divs to queue widgets when the DOM is ready
$(function() {
    $("#uploader").pluploadQueue({
        // General settings
        runtimes : 'gears,html5,flash',
        url : 'index.php?action=upload',
        max_file_size : '1mb',
        chunk_size : '1mb',
        unique_names : false,
        // redirect mod
        preinit : attachCallbacks,
        
        // Specify what files to browse for
        filters : [
            {title : "Allowed files", extensions : "jpg,gif,png,txt,doc,docx,pdf,zip"}
        ],

        // Flash settings
        flash_swf_url : 'js/plupload.flash.swf'

    });

    // Client side form validation
    $('form').submit(function(e) {
        var uploader = $('#uploader').pluploadQueue();

        // Files in queue upload them first
        if (uploader.files.length > 0) {
            // When all files are uploaded submit form
            uploader.bind('StateChanged', function() {
                if (uploader.files.length === (uploader.total.uploaded + uploader.total.failed)) {
                    $('form')[0].submit();
                }
            });  
            uploader.start();
        } else {
            alert('You must queue at least one file.');
        }

        return false;
    });
});

// added redirect function after uploaded
function attachCallbacks(uploader) {
uploader.bind('FileUploaded', function(Up, File, Response) {
    // count total of uploaded files
    var u_count = uploader.total.uploaded;
    // get the length of uploaded files
    var f_length = uploader.files.length;
    // check the status and status of failed uploaded files
     if(!uploader.total.failed && Response.status == 200) {
      // redirect the page after successfully uploading images
        if((u_count+1) == f_length)  window.location.assign('index.php');
     } else {
     alert('Failed uploading'); return false;
       }
    })
}

</script>


#3 sasori

sasori

    Advanced Member

  • Members
  • PipPipPip
  • 315 posts

Posted 10 September 2013 - 07:37 AM

with regards to the issue, there's another thing, even if the response is "200" , if you check in firebug...you will see that there's 

"pink" colored bar in the timeline., does that mean incomplete upload? ..because the typical color of the "200" ok response is blue in firebug , right?



#4 jazzman1

jazzman1

    Advanced Member

  • Gurus
  • 2,453 posts
  • LocationMississauga, Canada

Posted 10 September 2013 - 10:16 AM

Red color link with status 200 OK, it sounds for me, that there is a security warning/error. What type of data are you expecting to be received from the server?






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com