Search code examples
phpandroidcordovasharing

Cannot access my computer IP through my mobile phone on same network with port


I am making an Android Application using Cordova(PhoneGap) which doesn't support PHP. However I can access it remotely on a server and execute, thereby returning html to display. But how to access PHP file on my computer through my android phone, execute the file using localhost port and return the html back on my display. Both devices are on the same network. I don't want to host the files on a domain as told by my project guide.


Solution

  • If I correctly understood your problem, you want to access the files hosted on your computer (localhost) by your phone? If you're on the same network you can do that simply by routing with your phone to your computers IP address. You can get your IP address by typing the following code in the command prompt (cmd.exe):

    C:\Users\yourname> ipconfig /all
    

    Now you can see your IPv4 address in your network. Navigate with your phones browser to that IP address using the same network. If you're using a localhost port, do not forget to type that port after the IP address.