我无法通过本地网络从 Android 手机访问我的整个本地网络

问题描述 投票:0回答:1

我一直在寻找类似的问题,但找不到和我有同样问题的人。

我使用的是XAMPP V3.2.2。我可以通过使用 Chrome(与我的笔记本电脑连接到同一网络)的 Android 手机访问本地网络,只需输入我的笔记本电脑 IPV4 地址,然后输入

/index.php/controller/id
(因为我使用的是 Codeigniter 框架)。所以我的 Android 手机的 Chrome 中的 URL 是这样的:

192.168.xx.xx/index.php/principal/index

此时我可以访问主体和管理网页(背景图像已加载,Bootstrap 和 CSS 也已加载)This is how it looks。但这里开始出现一些问题。

其中之一是主网页中的图像未加载。正如我所说,背景图像加载没有任何问题,但图库的图像未加载。

当我尝试使用管理员网页中的某些功能(例如“删除照片”或“上传图像”)时,出现另一个问题。当您按下“上传图像”表单(这里是 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>

我放代码只是为了说明,它在我的笔记本电脑上运行良好,我可以上传照片、删除它们、创建新类别等等。但正如我之前所说,当我尝试在手机中执行这些操作并按下提交按钮时,浏览器会向我显示此页面 -> Error page

所以,我希望有人遇到同样的问题并可以给我一个解决方案。

谢谢

android html codeigniter xampp localhost
1个回答
0
投票

好吧,我终于解决了问题...

在 Codeigniter Config.php 文件中,我更改:

来自

$config['base_url'] = 'http://localhost/';

$localIP = getHostByName(getHostName());
$config['base_url'] = 'http://'.$localIP.'/';

所以现在我动态地向 CodeIgniter 提供服务器 IP,现在移动设备可以从服务器 IP 搜索图像,而不是像之前使用“localhost”那样从自身搜索图像。

© www.soinside.com 2019 - 2024. All rights reserved.