问题描述
我的文件在Windows Store应用程序的上载过程中的一些问题。我得到了状态200,但是当我检查服务器有使用Apache服务器没有文件uploaded..I'm
我检查了微软后台传输样本的样本一>,但它与ASP .NET服务器工作。
I have some problems during the upload of file on windows store application. I got Status 200, but when I check the server there's no file uploaded..I'm using apache serverI've checked the Sample of Microsoft Background Transfer sample but it work with a ASP .Net server.
任何解决方案?
推荐答案
我要上传单个文件的时间,它为我,让我知道:
I need to upload one single file at a time, It works for me, let me know:
upload.php的:
<?php
$target = "data/";
$target = $target . basename( $_FILES['Filename']['name']) ;
if(move_uploaded_file($_FILES['Filename']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['Filename']['name']). " has been uploaded";
}
else {
echo "Sorry, there was a problem uploading your file.";
}
?>
C#code:
private async void StartMultipartUpload_Click(object sender, RoutedEventArgs e)
{
Uri uri;
if (!Uri.TryCreate(serverAddressField.Text.Trim(), UriKind.Absolute, out uri))
{
rootPage.NotifyUser("Invalid URI.", NotifyType.ErrorMessage);
return;
}
// Verify that we are currently not snapped, or that we can unsnap to open the picker.
if (ApplicationView.Value == ApplicationViewState.Snapped && !ApplicationView.TryUnsnap())
{
rootPage.NotifyUser("File picker cannot be opened in snapped mode. Please unsnap first.", NotifyType.ErrorMessage);
return;
}
FileOpenPicker picker = new FileOpenPicker();
picker.FileTypeFilter.Add("*");
IReadOnlyList<StorageFile> files = await picker.PickMultipleFilesAsync();
if (files.Count == 0)
{
rootPage.NotifyUser("No file selected.", NotifyType.ErrorMessage);
return;
}
List<BackgroundTransferContentPart> parts = new List<BackgroundTransferContentPart>();
for (int i = 0; i < files.Count; i++)
{
BackgroundTransferContentPart part = new BackgroundTransferContentPart("Filename", files[i].Name);
part.SetFile(files[i]);
parts.Add(part);
}
BackgroundUploader uploader = new BackgroundUploader();
UploadOperation upload = await uploader.CreateUploadAsync(uri, parts);
String fileNames = files[0].Name;
for (int i = 1; i < files.Count; i++)
{
fileNames += ", " + files[i].Name;
}
Log(String.Format("Uploading {0} to {1}, {2}", fileNames, uri.AbsoluteUri, upload.Guid));
// Attach progress and completion handlers.
await HandleUploadAsync(upload, true);
}
我使用的SDK样品的同一code。的数据/ 的文件夹是在同一文件夹中的 upload.php的我的URI是 HTTP://mySite/myApp/upload.php
I used the same code of The SDK sample. data/ folder is in the same folder of upload.php and my Uri is http://mySite/myApp/upload.php
这篇关于连接Windows 8的应用程序与Apache服务器(在Windows 8中后台传输)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!