locked
Access my pc file system from an app

    Question

  • Hi,

    I would like to write an app for Windows 8, that allow users to upload files in a server, and to download files from the same server.

    I found this, for doing such a thing with Javascript:

    Upload a file

    What I would like to know is: what is the syntax for making the app connect to my personal pc and upload the files there? At the beginning I'd like to avoid using a web hosting service.

    Thanks a lot if anybody has an answer!

    Giorgio

    Wednesday, July 04, 2012 3:18 PM

Answers

  • Hi

    The sample can be download here.

    The Code for upload:

    function uploadFile() {
            var filePicker = new Windows.Storage.Pickers.FileOpenPicker();
            filePicker.fileTypeFilter.replaceAll(["*"]);
    
            filePicker.pickSingleFileAsync().then(function (file) {
                if (!file) {
                    printLog("No file selected");
                    return;
                }
    
                var upload = new UploadOperation();
                var uriString = document.getElementById("serverAddressField").value;
                upload.start(uriString, file);
    
                // Persist the upload operation in the global array.
                uploadOperations.push(upload);
            });
        }

    Unfortuantely the BackgroundUploader.CreateUpload method really need a uri parameter.

    You need a service to provide a right url for this.


    • Edited by Dino He Thursday, July 05, 2012 3:23 AM
    • Marked as answer by Dino He Wednesday, July 11, 2012 3:13 AM
    Thursday, July 05, 2012 3:08 AM