问题
I have to upload a video file from an windows phone 8.1 app. I am using the BackgroundTrasfer sample but for the server side there is just a aspx script. But I need PHP.
I have found this PHP script
<?php
$target = "upload/";
$target = $target . basename( $_FILES['Filename']['name']) ;
$ok=1;
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.";
}
?>
Finally I get a 200 and no errors but there is no file on the server so I would say the server part is the problem? Where I can get a working server part script?
P.S. The directory "upload" exist in the same directory like the upload.php and has the rights 777.
回答1:
You need to do a multipart/form-data
request.
Try something like (pseudo code):
List<BackgroundTransferContentPart> parts =
new List<BackgroundTransferContentPart>();
var part = new BackgroundTransferContentPart("myFile");
part.SetFile(file);
parts.Add(part);
UploadOperation upload = await uploader.CreateUploadAsync(
uri,
parts);
var task = upload.StartAsycn().AsTask();
On PHP, explore the recevied files with print_r($_FILES)
.
来源:https://stackoverflow.com/questions/27428420/backgrounduploader-sample-does-not-work-on-apache-server-with-php