I'm having trouble understanding how to send an uploaded file's content to my ASPX server-side. This is for an HTML-4 implementation where File API isn't available on the client-side, and using .NET v4.0.

Here's what I have so far:

HTML on FileReceiver.aspx:

<input type="button" id="uploadFile" value="Upload" /> 
<div class="hidden">
    <form id="uploadFileForm">
        <input type="file" id="browseForFiles" />

(client-side) JS:

$("#uploadFile").click(function () {

$("#browseForFiles").change(function () {

$("#uploadFileForm").submit(function (e) {

    // prevent default action

    // send file to server
        url: "FileReceiver.aspx/ReceiveFile",
        type: "post",
        dataType: "multipart/form-data", // <---- is this right?
        data: ???, // <-------------------------- what goes here? 
        success: function(data) { 
            // do something on success 

(Server-side) FileReceiver.aspx.cs:

public static string ReceiveFile(??? receivedFile) // <-- what type goes here?
    // do something and return status

Please help fill in the two "???" in the codes above. Thanks in advance!

Related posts

Recent Viewed