【问题标题】:I can´t access my entire local web from Android phone via local network我无法通过本地网络从 Android 手机访问我的整个本地网络
【发布时间】:2017-12-02 00:16:14
【问题描述】:

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

我正在使用 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】:

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

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

    来自

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

    到

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

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

    【讨论】:

      猜你喜欢
      • 2011-03-10
      • 2015-07-25
      • 1970-01-01
      • 2021-07-16
      • 2023-03-29
      • 1970-01-01
      • 2017-07-19
      • 1970-01-01
      • 2013-08-10
      相关资源
      最近更新 更多