Send images through HTTP #618
-
hello, I'm confused about how to send images via http to my web server, I use PHP, is there an example code that I can get/learn? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
This automatically generated reply acts as a friendly reminder. Answers to your questions will most often come from the community, from developers like yourself. You will, from time to time, find that Axis employees answers some of the questions, but this is not a guarantee. Think of the discussion forum as a complement to other support channels, not a replacement to any of them. If your question remains unanswered for a period of time, please revisit it to see whether it can be improved by following the guidelines listed in Axis support guidelines. |
Beta Was this translation helpful? Give feedback.
-
this is my code
|
Beta Was this translation helpful? Give feedback.
-
Hi @syariffortask , |
Beta Was this translation helpful? Give feedback.
-
Hi @syariffortask , Start Webserver using PHPphp -S 10.176.12.32:8090 index.php Add Recipients:Rule and Action:Manual Trigger control in camera webpage:OutputPHP code (index.php)<?php
echo '<p>Hello World!</p>';
// Echo the request method (e.g., GET, POST)
error_log("Request Method: ". $_SERVER['REQUEST_METHOD'] . PHP_EOL);
// Echo the requested URI
error_log("Request URI: ". $_SERVER['REQUEST_URI']. PHP_EOL);
// Echo the user agent of the client
error_log("User Agent: ". $_SERVER['HTTP_USER_AGENT']. PHP_EOL);
// Echo the client's IP address
error_log("Client IP Address:". $_SERVER['REMOTE_ADDR']. PHP_EOL);
// Echo all request headers
echo 'Request Headers:' . PHP_EOL;
foreach ($_SERVER as $key => $value) {
if (substr($key, 0, 5) === 'HTTP_') {
$header = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($key, 5)))));
error_log($header . ': ' . $value);
}
}
// Echo the request body (if applicable)
echo 'Request Body:' . PHP_EOL;
// Generate a filename with the current timestamp in int64 format
$timestampInt64 = (int) (microtime(true) * 1000000);
$filename = './image/image_' . $timestampInt64 . '.jpeg'; // Adjust the file extension as needed
// Save the image
file_put_contents($filename, file_get_contents('php://input'));
echo 'Image saved as ' . $filename;
?> Hope this will help you to troubleshoot 😄 |
Beta Was this translation helpful? Give feedback.
Hi @syariffortask ,
For your reference, I am adding my test setup snapshots here:
Start Webserver using PHP
Add Recipients:
Rule and Action:
Manual Trigger control in camera webpage:
Output
PHP code (index.php)