簡體   English   中英

使用php腳本在Android應用中上傳圖片

[英]Uploading image in Android app using php script

嘿..我正在使用PHP腳本從android應用程序上傳圖像文件。 我使用HTTP Post函數上傳文件(我調用www.masterstroketech.org/postimage.php?fn=abc.png,然后發布圖像路徑)。 該文件正在服務器上創建,但大小為0字節。

如果我在000webhost.com的免費服務器上使用相同的腳本,則此腳本運行良好。 到底是什么問題?

php代碼如下:

   <?PHP
   $data = file_get_contents('php://input');
   if (!(file_put_contents($_GET['fn'],$data) === FALSE)) echo "File xfer completed.";    // file could be empty, though
   else echo "File xfer failed.";
?>

從php.net的file_get_contents文檔中提取:

Reading all script input is simple task with file_get_contents, but it depends on what SAPI is being used.

Only in Apache, not in CLI:
<?php
  $input = file_get_contents("php://input");
?>

Only in CLI, not in Apache:
<?php
  $input = file_get_contents("php://stdin");
?>

In Apache php://stdin will be empty, in CLI php://input will be empyt instead with no error indication.

因此,您的本地服務器配置似乎出現了問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM