2013-03-15 106 views
1

在三星dforum上,我找到了URL,它解释了一个函数startUpload()三星智能电视上传文件

但也在论坛中,我发现人们说通过任何方式上传文件是不可能的。如果是的话为什么三星提供startUpload()功能?

有没有人试过文件上传?请帮忙

+0

有链接的论坛话题的? – 2013-03-21 11:51:33

+0

伊万,你可以很容易地在samsungdforum.com找到这个 – 2013-03-26 06:57:07

+0

[这个线程](http://www.samsungdforum.com/SamsungDForum/ForumView/a56519250d733296?forumID=eb25ba9af878e288)建议上传部分工作 – 2013-03-26 07:44:28

回答

1

文档不正确。我在UE46ES8000上进行了测试,并成功从连接到电视的USB闪存驱动器上传文件。 OnComplete回拨而不是OnUploadComplete

到上传数据尾加字符串--END_OF_PART--。如果你从文件中删除它,你会得到你的原始文件。

function OnUploadComplete (msg) { 
    alert('***OnUploadComplete***' + msg); 
} 
function OnUploadProgress (msg) { 
    alert('***OnUploadProgress***' + msg); 
} 

function fnDnStatus (msg) { 
    alert('fnCallback' + msg); 
    var tArrResult = msg.split("?"); 
    for (var i=0; i < tArrResult.length; i++) { 
     alert("tArrResult[" + i + "] = " + tArrResult[i]); 
    } 
    // DownResult: If res=1 success, otherwise ERROR (see end of this file) 
} 

var DownloadPlugin = document.getElementById("pluginObjectDownload"); 
DownloadPlugin.OnUploadComplete = OnUploadComplete; 
DownloadPlugin.OnUploadProgress = OnUploadProgress; 
DownloadPlugin.OnComplete = fnDnStatus; 
var sever = '192.168.137.1', 
    port = 80, 
    header = 'Header-name: Header value', 
    body = '[[[FILE_BINARY]]]', 
    filePath = '$USB_DIR/sda1/textfile.txt', 
    uploadRatio = '10', 
    serverType = 1; 

DownloadPlugin.StartUpload(sever, port, header, body, filePath, uploadRatio, serverType); 

我不知道header参数的含义。而且我不知道如何指定服务器根以外的url。数据通过POST请求发送至http://192.168.137.1:80/

在服务器端我简单的脚本(http://192.168.137.1:80/index.php)保存它:

<?php 
    $t = file_get_contents('php://input'); 
    if(strlen($t) > 1){ 
     echo 'some data arrived'; 
    } 
    file_put_contents('input.txt', $t); 
?> 
+0

太棒了!在哪个服务器上进行文件上传?我们可以使用像“http://localhost/myapp/upload.php”这样的应用程序URL来替换IP吗? – 2013-04-02 12:24:49

+0

文件没有上传,文件被发送到POST请求到'http:// IP:port /',你需要自己保存在你想要的地方。我不知道你能否使用FQN。文档没有指定它,我没有尝试过。 – 2013-04-02 12:34:54

+0

它也发送jpg文件吗?我可以从app目录发送文件吗?目前我没有该设备。仅限仿真器。谢谢 – 2013-04-02 12:45:49