-4

I have a block printer that can be printed by sending POST data. My problem is that I have PHP running on the server, so I can't call 127.0.0.1 from there. It is not possible with JavaScript because of the CROS rule.

What is the solution? I'm interested in all solutions!

Thanks!

web216
  • 75
  • 4
  • 1
    Please clarify your question - I have read it several times and still don't understand the issue – Professor Abronsius Apr 07 '23 at 07:59
  • If the printer is connected to another computer, you'll need the IP address of this machine, and it must be within the same network like the webserver to directly call it. – Honk der Hase Apr 07 '23 at 08:18
  • @ProfessorAbronsius, yes: I have a printer that is connected to the local network and is waiting for POST methods at the following IP address: http://127.0.0.1:30000/ I have a website that is hosted on example.com and I use PHP If I were to call 127.0.0.1 on a server, of course it would not be good. But if I call it in ajax, it is not possible because of the CROS rule. – web216 Apr 07 '23 at 09:30

1 Answers1

0

You need to post data using iframe like this

<form target="myIframe" action="http://localhost/post.php" method="post">
    <input type="hidden" value="someval" />
    <input type="submit">
</form>

<iFrame src="" name="myIframe"></iFrame>

more examples at original post How do you post to an iframe?