Search code examples
c#xamppwindows-phone-8.1windows-8.1background-transfer

File upload from Windows Phone App - Test with Localhost Apache (XAMPP)


I want to upload a video file to a local server (apache over XAMPP) by using BackgrountTrasfer. I have a test folder (xampp/htdocs/test/) but get an 404 Error with "localhost/test"

I get no errors if I use just localhost but I can also find no file on the computer. Do I need special configuration of the apache or is my code bad?

private async void UploadFiles()
{
    Uri uri = new Uri("http://localhost:8080/test/");
    StorageFile videofile = await Windows.Storage.KnownFolders.VideosLibrary.GetFileAsync("vid.mp4");

    BackgroundUploader uploader = new BackgroundUploader();
    uploader.SetRequestHeader(FileName + ".mp4", videofile.Name);
    UploadOperation upload = uploader.CreateUpload(uri, videofile);

    await upload.StartAsync();
}

I see that I need a script on sever side. There is one if you download BackgroundTrasfer sample from MSDN but it is a aspx file. I need php. Any idea where to get one?


Solution

  • The emulator runs as a separate device from the local system: localhost is the emulator itself, not the host the emulator runs on.

    You'll need to set up your server so it is visible from outside of the local system and then connect to it with the host system's address. See MSDN's How to connect to a local web service from the Windows Phone 8 Emulator for more information. The article explains setting up on IIS rather than on Apache, but the general concept will be the same even if the server details are different.