2

ランタイムを「html4」に設定すると、すべてが完全に機能します。ファイルが完全にアップロードされていないことを除いて、他のすべてのランタイム (一度に複数のファイルを選択できるため優れています) は正常に動作しているようです。数キロバイト (42 / 28 / 50) 後、「100% 完了」と表示されます。ファイルは保管されており、不完全です。何か案は?

$("#uploader").plupload({
// General settings
runtimes : 'gears,flash,silverlight,browserplus,html5',
url : 'upload.ashx',
max_file_size : '10mb',
chunk_size : '1mb',
unique_names : true,

// Resize images on clientside if we can
resize : {width : 320, height : 240, quality : 90},

// Specify what files to browse for
filters : [
    {title : "Image files", extensions : "jpg,gif,png"},
{title : "Zip files", extensions : "zip"}
    ],

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

    // Silverlight settings
    silverlight_xap_url : 'js/plupload.silverlight.xap'
});

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

    // 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 at least upload one file.');

    return false;
});

アップロード.ashx:

Public Class upload : IHttpHandler を実装します

Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
    Dim chunk As Integer = If(context.Request("chunk") IsNot Nothing, Integer.Parse(context.Request("chunk")), 0)
    Dim fileName As String = If(context.Request("name") IsNot Nothing, context.Request("name"), String.Empty)

    Dim fileUpload As HttpPostedFile = context.Request.Files(0)

    Dim uploadPath = context.Server.MapPath("uploads")
    Using fs = New FileStream(Path.Combine(uploadPath, fileName), If(chunk = 0, FileMode.Create, FileMode.Append))
        Dim buffer = New Byte(fileUpload.InputStream.Length - 1) {}
        fileUpload.InputStream.Read(buffer, 0, buffer.Length)

        fs.Write(buffer, 0, buffer.Length)
    End Using

    context.Response.ContentType = "text/plain"
    context.Response.Write("Success")
End Sub

Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
    Get
        Return False
    End Get
End Property
4

0 に答える 0