如何使用php本機功能和Android獲取檔案
我在我的網站的私人部分做了一個功能,以獲取和顯示一個儲存庫的一些檔案.
以下是我做的功能:
function getFilesChantier($devis, $cp) { //Si dossier cp n'existe pas on le créé if (!file_exists(_DOCS_ . 'C' . $cp)) { mkdir(_DOCS_ . 'C' . $cp, 0777, true); fopen(_DOCS_ . 'C' . $cp . '/index.html', w); } if (!file_exists(_DOCS_ . 'C' . $cp . '/' . $devis)) { mkdir(_DOCS_ . 'C' . $cp . '/' . $devis, 0777, true); fopen(_DOCS_ . 'C' . $cp . '/' . $devis . '/index.html', w); } //On liste les fichiers pdf $repertoire = _DOCS_ . 'C' . $cp . '/' . $devis; if ($dossier = opendir($repertoire)) { while (false !== ($fichier = readdir($dossier))) { if ($fichier != '.' && $fichier != '..' && $fichier != 'index.php' && $fichier != 'index.html' && $fichier != 'Thumbs.db') { $nb_fichier++; // On incrémente le compteur de 1 $retour[$nb_fichier]['name_file'] = str_replace('/var/www/sp-batiment.com/htdocs/docs/C' . $cp . '/' . $devis . '/', '', $repertoire . '/' . $fichier); $retour[$nb_fichier]['url_file'] = str_replace('/var/www/sp-batiment.com/htdocs/', '', $repertoire . '/' . $fichier); $retour[$nb_fichier]['nb_file'] = $nb_fichier; $retour[$nb_fichier]['date_file'] = date("F d Y H:i:s.", filectime($repertoire . '/' . $fichier)); } } } return $retour; }
所有瀏覽器都可以正常工作,
以下是我網站的呈現
但是當我們轉向手機(Android Samsung)時,它不適用於谷歌Chrome瀏覽器,
它什麼都不顯示
我不知道我的功能有什麼問題,還是它正在打電話的事實?
呼叫的頁面是一樣的,只是瀏覽器改變(第一個是電腦上的經典的谷歌Chrome),另一個是三星Galaxy的谷歌.
任何幫助將不勝感激.
編輯:我使用bootstrap,下面我的表的程式碼
<div class="col-md-12"> <h3>Mes documents</h3> <table class="table table-bordered"> <thead> <tr> <th>#</th> <th><i class="fa fa-calendar"></i> Date</th> <th class="text-center">Type</th> <th>Fichier</th> <th>Options</th> </tr> </thead> <tbody> <tr> <td nowrap="">1</td> <td nowrap="">17-08-2016 </td> <td nowrap="" class="text-center"><span class="label label-danger" style="text-transform:uppercase;tex-align:left"><i class="fa fa-file-pdf-o"></i></span></td> <td nowrap=""> compément-de-devis-1.pdf</td> <td nowrap=""> <form action="php/download.php" method="post"> <button class="btn btn-dark btn-xs"><i class="fa fa-cloud-download"></i> Télécharger</button> </form> </td> </tr> <tr> <td nowrap="">2</td> <td nowrap="">04-08-2016 </td> <td nowrap="" class="text-center"><span class="label label-danger" style="text-transform:uppercase;tex-align:left"><i class="fa fa-file-pdf-o"></i></span></td> <td nowrap=""> autorisation-changement-de-façade.pdf</td> <td nowrap=""> <form action="php/download.php" method="post"> <button class="btn btn-dark btn-xs"><i class="fa fa-cloud-download"></i> Télécharger</button> </form> </td> </tr> <tr> <td nowrap="">3</td> <td nowrap="">03-08-2016 </td> <td nowrap="" class="text-center"><span class="label label-danger" style="text-transform:uppercase;tex-align:left"><i class="fa fa-file-pdf-o"></i></span></td> <td nowrap=""> devis-initial.pdf</td> <td nowrap=""> <form action="php/download.php" method="post"> <button class="btn btn-dark btn-xs"><i class="fa fa-cloud-download"></i> Télécharger</button> </form> </td> </tr> <tr> <td nowrap="">4</td> <td nowrap="">03-08-2016 </td> <td nowrap="" class="text-center"><span class="label label-danger" style="text-transform:uppercase;tex-align:left"><i class="fa fa-file-pdf-o"></i></span></td> <td nowrap=""> plan-du-batiment.pdf</td> <td nowrap=""> <form action="php/download.php" method="post"> <button class="btn btn-dark btn-xs"><i class="fa fa-cloud-download"></i> Télécharger</button> </form> </td> </tr> <tr> <td nowrap="">5</td> <td nowrap="">03-08-2016 </td> <td nowrap="" class="text-center"><span class="label label-danger" style="text-transform:uppercase;tex-align:left"><i class="fa fa-file-pdf-o"></i></span></td> <td nowrap=""> facture-acompte-n-1.pdf</td> <td nowrap=""> <form action="php/download.php" method="post"> <button class="btn btn-dark btn-xs"><i class="fa fa-cloud-download"></i> Télécharger</button> </form> </td> </tr> </tbody> </table> </div>
在您的html程式碼中,沒有問題,因為我在我的移動裝置上執行它的工作正常.
一個小的錯字錯誤tex對齊到您的程式碼中的文字錯誤
您可以通過您的PC檢查您的移動谷歌Chrome瀏覽器中的HTML程式碼.檢查這個連結
ofollow,noindex" target="_blank">https://developers.google.com/web/tools/chrome-devtools/debug/remote-debugging/remote-debugging?hl=en
從那裡你可以檢查錶行是從你的PHP程式碼充氣還是你的html程式碼有任何問題
希望這將有所幫助
程式碼日誌版權宣告:
翻譯自:http://stackoverflow.com/questions/38910837/how-to-get-file-using-php-native-functions-and-android