duanqiao1880 2010-10-15 08:28
浏览 90

Plupload自定义配置问题,有什么想法吗?

I've been working for a bit on this code, making in function just as I'd like it, but in the end I guess I missed something pretty big: the files don't seem to be uploading. The progress bar has been perfectly tweaked, the dialog box works well, just no files are being uploaded.

What's going on?

My Javascript:

    fileCount = 0;
    barWidth = 0;

$(function() {
var uploader = new plupload.Uploader({
    runtimes : 'flash',
    browse_button : 'pickfiles',
    max_file_size : '10mb',
    url : 'js/upload/upload.php',
    resize : {width : 700, height : 700, quality : 90},
    flash_swf_url : 'js/upload/plupload.flash.swf',
    filters : [
        {title : "Image files", extensions : "jpg,gif,png"},
    ]
});

uploader.bind('Init', function(up, params) {

});

uploader.bind('FilesAdded', function(up, files) {
    $.each(files, function(i, file) {
        fileCount ++
        $('#uploadfiles').fadeIn(200);
        $('#filelist').append(
            '<div id="' + file.id + '">' +
            file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' +
        '</div>');
    });
});

uploader.bind('FileUploaded', function(up, file) {
    console.log(file.name);
    $('#'+ file.id).fadeOut(200);
});

uploader.bind('UploadProgress', function(up, file) {

    barWidth = barWidth+(file.percent/fileCount)

    $('#progressBar').animate({"width":barWidth+"%"},300);
        if (barWidth == 100 ) {$('#progressBox').delay(2000).fadeOut(200)};
    });

$('#uploadfiles').click(function(e) {
    e.preventDefault();
    $('#filelist').fadeIn(200, function() {
        $('#progressBox').fadeIn(200, function() {
            uploader.start();
        });
    });
});

uploader.init();
});

My HTML (updated per comment below):

<form method="post" action="js/upload/upload.php" enctype="multipart/form-data">
    <div>
        <button id="pickfiles" href="#">Add...</button> 
        <button id="uploadfiles" href="#">Upload</button>
        <br />
        <div id="filelist"></div>
        <div id="progressBox"><div id="progressBar"></div></div>
    </div>
</form>
  • 写回答

1条回答 默认 最新

  • duandanai6470 2010-11-11 02:38
    关注

    I think your answer lies in what the upload.php file does when it receives the post. Check the file associated wiuth your config line: url : 'js/upload/upload.php' I had a similar problem (in ASP.NET) where the upload directory did not exist.

    Hope that helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置