Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


Windows8 upload image to php server using winjs xhr POST


Problem is upload_field index not defined error at php please find below code base used for uploading image from windows 8.

function pickImage() {
// Create the picker object and set options
var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail;
openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary;
// Users expect to have a filtered view of their folders depending on the scenario.
// For example, when choosing a documents folder, restrict the filetypes to documents for your application.
openPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]);

// Open the picker for the user to pick a file
openPicker.pickSingleFileAsync().then(function (file) {
    if (file) {
        // Application now has read/write access to the picked file
        WinJS.log && WinJS.log("Picked photo: " + file.name, "sample", "status");
var fdata = new FormData();
fdata.append('upload_field',file);

       WinJS.xhr({
            type: "post",
            url: "http://localhost/imgupload.php",
            data: fdata,
            // headers: { "Content-type": "application/octet-stream" }

        }).done(function (result) {
            console.log(result.responseText)
        });

        document.getElementById('imgCapture').src
    = window.URL.createObjectURL(file);
    } else {
        // The picker was dismissed with no selected file
        WinJS.log && WinJS.log("Operation cancelled.", "sample", "status");
    }
});

}

asked Sep 13, 2013 in Microsoft Window 8 by rajesh
edited Sep 12, 2013
0 votes
116 views



Related Hot Questions



Government Jobs Opening


...