BackgroundUploader Sample does not work on Apache Server with PHP

谁说胖子不能爱 提交于 2020-01-17 03:55:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!