Pregunta

I want to get the name of image using foreach or each in plupload. I have old code here but is not working

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

        if(uploader.files.length > 0 )
        {
            uploader.each(files, function (file) {
                alert(file.name);
            });
        }

there is something I need to modify? please help. thank you.

¿Fue útil?

Solución

You may try this (I guess you don't really need the if clause in this context)

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

if (uploader.files.length > 0) 
{
   for(var i=0; i<uploader.files.length; i++)
       {
        alert(uploader.files[i].name);
       };
}

or this, which won't work on older browsers. (IE8 and older)

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

if (uploader.files.length > 0) 
{
    uploader.files.forEach(function (file) {
        alert(file.name);
       });
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top