![](/img/trans.png)
[英]How to config computer/phone network to access local web server via USB (Android:GAE)?
[英]I can´t access my entire local web from Android phone via local network
我一直在尋找類似的問題,但找不到與我有相同問題的人。
我使用的是 XAMPP V3.2.2。 我可以從我的 Android 手機和 Chrome 訪問我的本地 web(它連接到與我的筆記本電腦相同的網絡),只需輸入我的筆記本電腦 IPV4 地址,然后/index.php/controller/id
(因為我是使用 Codeigniter 框架)。 所以我的 Android 手機的 Chrome 中的 URL 是這樣的:
192.168.xx.xx/index.php/principal/index
此時我可以訪問主體和管理網頁(加載背景圖像以及 Bootstrap 和 css)這就是它的樣子。 但是這里開始出現一些問題。
其中之一是未加載主網頁中的圖像。 正如我所說,背景圖像加載沒有任何問題,但畫廊的圖像沒有加載。
當我嘗試使用管理員網頁中的某些功能(如“刪除照片”或“上傳圖像”)時出現另一個問題。 當你按下提交按鈕時,例如“上傳圖片”表單(這里是 html):
<form action="http://localhost/index.php/principal/subir_foto" enctype="multipart/form-data" method="post" accept-charset="utf-8">
<label class='control-label'>Seleccionar:</label>
<input id="img" required="true" type='file' name='imagen'/>
<div class='input-group'>
<label class='control-label'>Descripción:</label>
<input type='text' name='alt' placeholder='Descripción'>
</div>
<div class='input-group'>
<input type='submit' name='agregar' value="Agregar">
</div>
</form>
我放代碼只是為了說明,它在我的筆記本電腦上運行良好,我可以上傳照片、刪除照片、創建新類別等等。 但正如我之前所說,當我嘗試在手機中執行這些操作並按下提交按鈕時,瀏覽器會顯示此頁面 ->錯誤頁面
所以,我希望有人有同樣的問題,可以給我一個解決方案。
謝謝
好吧,我終於解決了這個問題......
在 Codeigniter Config.php 文件中,我更改:
從
$config['base_url'] = 'http://localhost/';
到
$localIP = getHostByName(getHostName());
$config['base_url'] = 'http://'.$localIP.'/';
所以現在我動態地給 CodeIgniter 服務器 IP,現在移動設備可以從服務器 IP 搜索圖像,而不是像以前使用“本地主機”那樣從它們自己搜索圖像。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.