Well I think I found what was causing the error.
Is the Zend Debugger (which was running only with Firefox), when I close it then it works fine in Firefox too.

Anyway, if someone knows why this happens every explanation is always welcome.

I'm listening to window.onbeforeunload to alert the user when leaving my form without submit it.

and plupload is firing the event when I click the "add files" button.
This only happens with HTML5 and in Firefox (7).
With HTML5 in Chrome (14) the event is not fired.
I have not tested it in IE+HTML5 (because I don't have IE9 tongue)

@david can you confirm if this is a bug of the plugin or Firefox? and maybe a workaround for it?

Thanks !

EDIT:
more info: I'm using the last version of plupload (1.5.1.1) and I have a drop down for selecting the method (html5, flash, etc), it's automatically by default (with html5 first). And if I select HTML5 explicitly (even when plupload is running HTML5 already) then everything works fine (the window.onbeforeunload is not fired).

this is the code for the select box:

// this creates the plupload queue and return a reference to it
var uploader = createUploader('');

$("#select-upload-runtime").change(function()
        {
            destroyUploader(uploader);
            uploader = createUploader($(this).val());
        });


function destroyUploader(uploader) {
    uploader.destroy();
}

What do you mean with jQuery UI being more robust? do you recommend to use the UI version?

What are the pros of using the jQuery version then? the size?

And, last but not least, what are the dependencies of UI Widget, I mean I think we need jQuery UI for that, but not the complete jQuery UI...

4

(16 replies, posted in General discussion)

I've added a tentaive reply to one of the questions without answers (3rd post).

How to obtain a reference to the uploader?

This is how you get uploader instance:

// in Core API
var uploader = new plupload.Uploader({
...
});

// for Queue widget
$("#uploader").pluploadQueue({
...
});
var uploader = $("#uploader").pluploadQueue(); // notice blank parenthesis 

// for UI widget
$("#uploader").plupload({
...
});
var uploader = $("#uploader").plupload('getUploader');

Can you complete it davit?

Thanks!

Thanks davit, anyway, I'm doing that in this way now:

uploader.destroy();
uploader = crearUploader(runtime here);

basically, destroy the uploader, and create it again with a new runtime, it's not elegant but I think is working.

Is possible to change the runtime dinamically and manually?
I'm having problems with flash runtime in some files, and the problems seems to be random. I get a #2032 IOError (I submit the bug here: https://github.com/moxiecode/plupload/issues/303).

and I want to, at least, permit the user to change the runtime if flash doesn't work well for him.

Is possibe to do this?

Thanks!

OK, this is my solution, inside your Error event, execute this (only works if you are using Queue widget):

$(".plupload_buttons,.plupload_upload_status").css("display", "inline");
$(".plupload_start").addClass("plupload_disabled");
$('span.plupload_total_status,span.plupload_total_file_size').hide();

I'm getting an error in flash runtime and with only one file (other files works fine, and this problematic file works file with other runtimes), I don't know why, the error is #2032:
http://www.flashplayerfixer.com/flash-p … r-2032.php

I'm trying to solve that problem (if you know what could be the cause please tell me), but for now I have another problem:

After the error I cannot use the uploader anymore, the buttons for brows and upload disspaear.

Is possible to re enable the uploader?
I tried with up.init() and up.refresh without success.

Thanks!

PS: When I find an aswer to this problem I will update the FAQs with this question too.

9

(16 replies, posted in General discussion)

Thanks for the edit davit.
I've changed the answer for the image size limit in Flash too.
And cleaned the thread.

In the second post I put the questions with answers, and in the third the qustions without answers to make it easy to read.

I will need help with this, I hope you and other users can help too.
I'm still learning plupload and some of my replies are vague (for example the list of errors)

10

(11 replies, posted in General discussion)

thanks davit, can you explain us how do you achieve the 8091x8091 limit in Flash?   
Which is the min Flash version required for plupload?

11

(1 replies, posted in General discussion)

Hi rockinelle, I'm trying to write (and to motivate other users to write too) some type of FAQs, you can read them here:
http://www.plupload.com/punbb/viewtopic.php?pid=3962

12

(1 replies, posted in General discussion)

Well, I think that's because when we use "streams" (php://input) we can't send those parameters with POST so plupload uses GET in that case.

13

(16 replies, posted in General discussion)

WITHOUT REPLIES (or without checked answers)
Please help to answer them

How to obtain a reference to the uploader?
If you are using the UI widget, I think you can execute this:

var uploader = $('#uploader').plupload('getUploader');

And I think that for Queue Widget you must use this:

// note that pluploadQueue is called without parameters
var uploader = $('#uploader').pluploadQueue();




What is the max file size that we can upload?


When to use multipart and when to use stream?


Common problems and solutions?


How to re-enable the uploader after an error in Queue Widget?
I don't know if this is the best way, but at least is working, you can execute this for enabling the upload buttons again after an error:

    $(".plupload_buttons,.plupload_upload_status").css("display", "inline");
    $(".plupload_start").addClass("plupload_disabled");
    $('span.plupload_total_status,span.plupload_total_file_size').hide();

Best practices or recommendations?
(for example try to use Gears and SIlverlight before Flash if you need to resize or upload big images)

14

(11 replies, posted in General discussion)

What do you mean with faster? Silverlight is in many situations even faster than Flash (and I'm a Flash developer, never used Silverlight tongue), although the silverlight file is bigger (I don't know why).

But the most important here I think is the capabilities.
HTML5 can't resize the image in all browsers and Flash can't resize big images (and +12Mpx cameras are very common these days).

That's why I'm intrigued with davit's suggestion.

15

(1 replies, posted in General discussion)

why upload.php is using $_REQUEST instead of $_POST?

// Get parameters
$chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
$chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';

you need to download it from GIT:
http://github.com/moxiecode/plupload
check the FAQs:
http://www.plupload.com/punbb/viewtopic.php?pid=3949

Regards!

PS: also note that there's an error in the translations, because the string replacement is case sensitive, 'Start Upload' should be 'Start upload'.

17

(16 replies, posted in General discussion)

Where is a quick tutorial?
http://www.plupload.com/punbb/viewtopic.php?id=787


How to get the reference to uploader object?

// in Core API
var uploader = new plupload.Uploader({
...object with options here
});

// for Queue widget
$("#uploader").pluploadQueue({
...object with options here
});
var uploader = $("#uploader").pluploadQueue(); // notice blank parenthesis 

// for UI widget
$("#uploader").plupload({
...object with options here
});
var uploader = $("#uploader").plupload('getUploader');

you can learn more about the options accepted by plupload here:
http://www.plupload.com/documentation.php#configuration




What's the diffrence between custom uploader, Queue WIdget and UI Widget?
Core API (runtimes) creates input element, which when clicked opens file dialog. The rest is upon developer - he is the one to start upload, to handle progress and complete events.

Widgets - Queue and UI on the other hand encapsulate that additional logic and provide particular html structure and look.
Queue is a JQuery Plugin
UI is a JQuery UI Plugin


What are the limitations in Flash runtime?
If you are using image resize, the limit image size is:
8191x8191px
you can read more here:
http://www.plupload.com/punbb/viewtopic.php?id=602
How to translate the widgets?
Just add something like this:

plupload.addI18n({
    'Select files' : 'Elija archivos:',
    'Add files to the upload queue and click the start button.' : 'Agregue archivos a la cola de subida y haga click en el boton de iniciar.',
    'Filename' : 'Nombre de archivo',
    'Status' : 'Estado',
    'Size' : 'Tamaño',
    'Add files' : 'Agregue archivos',
    'Stop current upload' : 'Detener subida actual',
    'Start uploading queue' : 'Iniciar subida de cola',
    'Uploaded %d/%d files': 'Subidos %d/%d archivos',
    'N/A' : 'No disponible',
    'Drag files here.' : 'Arrastre archivos aquí',
    'File extension error.': 'Error de extensión de archivo.',
    'File size error.': 'Error de tamaño de archivo.',
    'Init error.': 'Error de inicialización.',
    'HTTP Error.': 'Error de HTTP.',
    'Security error.': 'Error de seguridad.',
    'Generic error.': 'Error genérico.',
    'IO error.': 'Error de entrada/salida.',
    'Stop Upload': 'Detener Subida.',
    'Add Files': 'Agregar Archivos',
    'Start Upload': 'Comenzar Subida.',
    '%d files queued': '%d archivos en cola.'
});

TIP: there are many translations ready, you must download them from GIT:
http://github.com/moxiecode/plupload
and just add the "js" file after plupload.js.
for example:

<script type="text/javascript" src="js/plupload.js"></script>
<script type="text/javascript" src="js/es.js"></script>

NOTE: Also note that, at the time of writing this, there's an error in the translations, because the string replacement is case sensitive, 'Start Upload' should be 'Start upload'.



How to manage server response?
You can send anything you want from your server, and it will be accessible from these events:
"FileUploaded"
"ChunkUploaded"
see the docs: http://www.plupload.com/plupload/docs/a … leUploaded

Despite the name of those events, ther are not synonymous of a success upload and saved file, you can have an error in your server side. In that case you should return the error and do somehing with it in the above events.

for example:

uploader.bind('FileUploaded', function(up, file, info) {
      alert(info);
});


How to manage errors?
For server side errors, see the above question.
For local errors you should listen (bind) the "Error" event. This event is triggered always with a "code" and a "message" (in english, you can translate it, see the next question).

NOTE: also you can receive a Server side error in the "Error" event if your server (or you) responds with a status other than 200.



How to translate errors?
In the same way that you translate the widgets. Also, if you are using the "js" files inside i18n folder (you need to download the sources from GIT) you probably have the errors translated too.


What are the errors returned in "Error" event?

Generic error for example if an exception is thrown inside Silverlight.
code: -100
message: Generic error.

HTTP transport error. For example if the server produces a HTTP status other than 200.
code: -200
message: HTTP Error.

Generic I/O error. For exampe if it wasn't possible to open the file stream on local machine.
code: -300
message: IO error.

Generic I/O error. For exampe if it wasn't possible to open the file stream on local machine.
code: -400
message: Security error.

Initialization error. Will be triggered if no runtime was initialized.
code: -500
message: Init error.

File size error. If the user selects a file that is to large it will be blocked and an error of this type will be triggered.
code: -600
message: File size error.

File extension error. If the user selects a file that isn't valid according to the filters setting.
code: -601
message: File extension error.
       
Runtime will try to detect if image is proper one. Otherwise will throw this error.
code: -700
message:
       
While working on the image runtime will try to detect if the operation may potentially run out of memeory and will throw this error.
code: -701code: -200
message:
message:
       
Each runtime has an upper limit on a dimension of the image it can handle. If bigger, will throw this error.
code: -702
message:


NOTE: the above is a list extracted from the source code of plupload, but I think there are some errors that are triggered when using some runtimes only, and even more, there are errors that are not triggered at all ! (for example IMAGE_FORMAT_ERROR)

Also, there are error events with more properties than just "code" and "message", for example, if we are using gears:

up.trigger('Error', {
                                    code : plupload.HTTP_ERROR,
                                    message : plupload.translate('HTTP Error.'),
                                    file : file,
                                    chunk : chunk,
                                    chunks : chunks,
                                    status : req.status

This is a bit confusing...



What are the chunks and how they work?
plupload can brean your files in "chunks", and send each chunk to the server in a different POST request.
This is useful when we are uploading big files that exceed the max_size limit for POST requests in our server.

Also check this post for more info and recommendations about chunks:
http://www.plupload.com/punbb/viewtopic.php?id=840


How to upload big files? (bigger than our server max file size)

Using the chunks is the only way one can bypass server-side "max file size" limitation. Although some shared hostings as it seems directly monitor file sizes in temp folders and drop the connection if they detect violation (for example Strato is known to behave like this).



What is the difference beween multipart and stream?


Multipart (multipart/form-data) upload is usual way to send files to server. This is what browsers use to submit forms with files. When Plupload is set to multipart mode (default), it will upload files the way one would expect (for PHP it will populate $_FILES array, etc). In non multipart mode, files are sent as binary streams and it's up to implementer to receive them properly (for PHP check: php:// — Accessing various I/O streams)


What happens if we bind events before calling init()?

In addition to the event listeners that one might bind to uploader object, there are also ones already defined, that Plupload uses internally. For example there is a listener for FilesAdded event, which does filtering of the files and if they pass it, adds them to the queue.

When you bind event listeners before the call to uploader.init(), they are binded before internal listeners and are executed accordingly. This is done for users to have ability to expand or override internal event handlers for whatever reason. If false is returned from the user defined event handler, which was binded to the event before the internal one, internal is not executed anymore.

When event handler is binded after the call to uploader.init(), all internal handlers run without intervention, intended or not. And unexpected results are simply excluded.

When do we need to use "up.refresh();"?

File dialog trigger is positioned absolutely above the browse_button element, so if Plupload html structure is not appended to the same parent (check container option) and browse_button element gets moved for some reason, one needs to call up.refresh(); to reposition file dialog trigger.

What is the difference between "UploadFile" and "BeforeUpload" events?

BeforeUpload is triggered before file is uploaded, while UploadFile triggers after upload is already started (for the latter to be true UploadFile should be binded after uploader.init()).



Why the upload continue even after calling stop?
Currently ( 04/2011 ) plupload is not able to cancel remaining chunks and will continue to upload them, until all of them are uploaded and then will stop. This will be fixed in next minor release. Major update, which is on schedule now, will make chunking feature much more convenient and stable.

18

(16 replies, posted in General discussion)

Can we make a FAQ?

simple and concise.

I'm starting the FAQ with these questions:
(please help to make this list bigger and better)


In the second post I will put the questions with answers, and in the third the qustions without answers to make it easy to read.



Regards !
Enrique.

PS: offtopic: why the creators of TinyMCE are not using it in this forum? sad

19

(11 replies, posted in General discussion)

HTML5 and FLash?
from the features:
http://www.plupload.com/index.php

HTML5: Image resizing is only possible on Firefox 3.5+ and only at a fixed quality. WebKit/Opera doesn't support direct data access to the selected files.

and Flash can't manage big images (in FP10 the limit is 16,777,215 = 4096x4096 for squared images)

Is not better to try Gears and Silverlight before?
I was thinking in this:

gears, silverlight, flash, html5

I will explain it better:
Usually I'm debugging my php files with "echo" lines, and see what type and content has my vars, etc.
I can't use upload.php directly, I'm using Kohana, with a lot of modules (like Authentication), I need to adapt the hole upload.php to my code and I need to understand every detail.

If I can echo every line in upload.php then I can see how many times is executed, what is the content, where, etc.

@davit can you help me with this? how can I "echo" every line in upload.php?

Thanks !!

Hi ! I'm new in plupload.

How can we control the output? I've read this:

You need to add renaming logic to your server-side upload handler (probably upload.php), then package some JSON response with new name, url and whatever else you require and send it back to Plupload, then use FileUploaded event to handle JSON response on client-side. Quite straightforward.

source: http://www.plupload.com/punbb/viewtopic.php?id=708

but I can't find FileUploaded in the API to understand how to code that event, also I can't understand how upload.php works, because if I see it right it only outputs (when verything is OK) this:

die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');

where is the information there? because the example works great, but I can't understand how the output works.

I was searching a good uploader, and I chose plupload between many options, because I think is the best, but I don't understand anything :S
I think it's very important a better documentation, also some tutorials, or at least a downloable API (for search and fast reading).