2013-03-15 152 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