I have built the Esp32-cam video streaming with Arduino-IDE. This works via my Wifi network. When I login on my router then I can see that the ESP32-Cam is connected (192.168… etc). When I type that address in the URL bar of my browser then I get a Black screen with the Toggle OV2640 settings tabel. When I press the Still button I see a photo right of the tabel. But this is all within the Wifi network.
Now I want to send this picture to my website e.g. /webcam/index.html on the internet. On that webcampage there is a html line <a href=”http://web.net/index.html”><img src=”http://web.net/cam.jpg” alt=”cam.jpg”></a>
Normally I take a photo with my camera and upload that photo with an ftp program to my website as cam.jpg.
Now I like to place the ESP32-cam at my window and the “software” uploads (at an adjustable interval) its picture to my website.
If possible , after the ESP32-cam having made the photo, it’s going into sleepmode. Then may be possible that I feed the module with a solar battery.
Can I use one of the published example projects from your esp32-cam projects on https://randomnerdtutorials.com/projects-esp32-cam/ to realise that automatically?
I think the following tutorials might help:
The second link has the example to take a photo every 30 sec, which is one wish. But do I understand it right that the projects in both links are using a Raspberry Pi? I do not have such one. Can I use an ESP32 device as an alternative?
If I understand it right, there should be that picture made by the ESP32-cam anywhere in my WIFI network because I can observe that picture already with looking to 192.168…etc. So only one step to do is take that picture (as a jpg) to my webserver. Or is the ftp. program that I am using for that upload to my webserver now the task that your Raspberry Pi is doing otherwise? I am also using a very small program called Fwink to upload pictures. That piece of software can upload .jpg pictures, with a time interval when set, or directly from a connected digital camera.
So I was thinking if that digital camera could be the videostream or pictures made by the ESP32-CAM.
Perhaps you can give me a hint if I am on the right way.
You don’t need the Raspberry Pi. The article mentions that you can use the example with a local server (Raspberry Pi) or with your own cloud server. In both cases, all pictures are saved on the server (Raspberry Pi or your cloud server).
After reading your answer I’m not sure if I understood your question properly??
Can you better explain where you want to send the pictures to?
As an intermediate step I have tried an other project. I tried “ESp32-cam HTTP POST Photos to Local or Cloud Server using PHP and Arduino-IDE”. I started in section 2.2
I use my own domain where my website is hosted. In this text I use (for convenience) https://www.abc.com
I have logged on to the webserver and created upload.php, gallery.php and a folder uploads.
When I look into the map https://www.abc.com/ I see:
Just a remark. In your example-picture of the cPanel filemanager I do not see gallery.php.
I have edited the upload.php with your text (starting with <?php)
When I check the PHP Url by typing the URL in my browser:
https://www.abc.com/upload.php then I get:
“Sorry, only JPG, JPEG, PNG & GIF files are allowed.Sorry, your file was not uploaded.”
Then I created the .ino file with a copy of your ESP32-CAM Code.
I modified that .ino file by replacing the string servername with https://www.abc.com
I uploaded and started to run the sketch. ESP32-CAM is connected to WFI successfully. It shows the ESP32-CAM IP address.
Then it is trying to connect to https://www.abc.com but that failed.
I am wondering how the sketch could login without a password to upload a picture to the webserver of https://www.abc.com? However I looked up in amazement by reading that sometimes the connection was successful now (unfortunately no pictures on the webserver).
I looked into my webpage https://www.abc.com/uploads and the browser showed:
You don’t have permission to access /uploads/ on this server.”
I then looked into the folder /uploads/ of the (webserver) filemanager. -> “No data found”
How can the message in the serial monitor show that the connection to the server https://www.abc.com is successful without a password?
During upload trials of several pictures there are also often messages Connection to server: https://www.abc.com/ failed.
I expect that I have to specify the username and password in the sketch, like a FTP program.
Then the ESP-CAM is able to upload pictures to the webserver?
Do you have any idea what this issue may be?
Meanwhile I have changed to another wifi network with a router very close to the ESP32-CAM providing a good signal now. The story in short:
Still trying with “ESp32-cam HTTP POST Photos to Local or Cloud Server using PHP and Arduino-IDE”.
Started in section 2.2 and in this text I use (for convenience) https://www.abc.com
Using the FileManager of my web account I have now in the map https://www.abc.com/
File upload.php edited with your text (starting with <?php)
https://www.abc.com/upload.php in my browser shows:
“Sorry, only JPG, JPEG, PNG & GIF files are allowed.Sorry, your file was not uploaded.”
The .ino file is a copy of your ESP32-CAM Code, with example.com replaced by https://www.abc.com as the String servername.
After a successful compile and upload the serial monitor shows after every 30 seconds:
Connecting to server: https://www.abc.com
<head><title>400 Bad Request</title></head>
<center><h1>400 Bad Request</h1></center>
After using the Reset button of the ESP32-CAM the Serial Monitor shows:
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
mode:DIO, clock div:1
ho 0 tail 12 room 4
Do you have any idea what caused this 400 Bad Request?
If I FTP something to my website I have to login with my Username and Password.
How is that done here?
Where is you php code hosted? If you’ve followed our instructions, did you change the permissions of the uploads folder to allow images to be stored? If you’re in a cPanel server, you also need to change the permissions to allow image storage:
You might need to right-click on the uploads folder on the cPanel and change the permissions to allow write/read/delete.
That project does not require any password to publish images to the server. It’s an open URL. But, you can add security afterwards (this project was meant to run locally for my needs, otherwise, it is recommended to add authentication in the request).
My php code is hosted in /www/abc.com/, if you mean the file upload.php. This file is located in /www/abc.com/ as upload.php (permission 644).
If I open the file then I read the code that I copied the snippet from your projectsite (https://randomnerdtutorials.com/esp32-cam-http-post-php-arduino/) in para 2.2 (raw code).
If I open the file /www/abc.com/gallery.php (permission 644) then this file is empty.
If I look into /www/abc.com/uploads (permission 755) then the message “no data found”
I have read in your section 2.1 for the raspberryPI how to change the /WWW/HTML permission.
Although this is not mentioned in para 2.2 I have given permission 777 for /WWW, /WWW/www.abc.com, /WWW/www.abc.com/Uploads, /WWW/www.abc.com/upload.php and /WWW/www.abc.com/gallery.php.
With that setting I have run the sketch with server name “https://wwww.abc.com”. Then I get in the serial monitor the message “Connection Successful” and “400 Bad Request”
With that setting I have run the sketch with server name “www.abc.com”. Then I get in the serial monitor the message “Connection Successful” and 400 Bad Request “301 Moved Permanently”
With that setting I have run the sketch with server name “abc.com”. Then I get in the serial monitor the message “Connection Successful” and 400 Bad Request “301 Moved Permanently” as well.
These three possibilties are als done by setting the above mentioned directories and files in their default permissions. Resulted in the same messages.
You wrote: “If you’re in a cPanel server, you also need to change the permissions to allow image storage:”
and “You might need to right-click on the uploads folder on the cPanel and change the permissions to allow write/read/delete.”
In my server situation it is another Filemanager. There I have changed the permission as described above into 777. I think then storage of images is allowed and the /Uploads folder allows read/write/delete.
I will also try, if you have such an example, that the ESP32-CAM, connected to WIFI, only stores the images (all with the same filename) as jpg (like cam.jpg) on my harddisk. Then I have a program that can upload the cam.jpg from disk with a settable time interval.
Meanwhile I have done a lot of trials uploading a ESP32-CAM pic to the /uploads folder on my webserver (“www.abc.com” ). Unfortunately without success.
I have have gone through your project “ESP32-CAM Post Images to Local or Cloud Server using PHP (Photo Manager)” thoroughly.
I edited upload.php and gallery.php with your raw code snippets. After uploading the sketch every 30 seconds I read in the serial monitor :
Connecting to server: “www.abc.com”
<head><title>301 Moved Permanently</title></head>
<center><h1>301 Moved Permanently<h1></center>
I suppose the 301 Failure is the answer of the webserver.
I forget the preceding “a2” at the beginning and the “0” at the end of the message for now.
I have changed the permission of “www.abc.com” into 777 read/write/delete/execute. Message “301 Moved Permanently” is still coming.
I have deleted both php files and the folder /uploads. Message “301 Moved Permanently” is still coming.
What can I do more? Any idea what this can be?
The message “301 Moved Permanently” was due to a webserver domain security setting that determines the redirect of incoming HTTP traffic to HTTPS on the webserver. It is this setting that determines whether or not the ESP32-CAM photos (or any other type of file I guess) may allowed to be passed through.
But as you said before, it is recommended adding security afterwards (add authentication in the request).
This thread may be closed.
Instead of abc.com I could also have used example.com as a domain name , as in your high-level overview in section 2. Cloud server (Bluehost hosting solution) as virtual name in this forum for my domain name.
I have built exactly what is indicated in that overview.
The ESP32-cam images are neatly stored in gallery.php provided I have disabled the “Redirect from incoming HTTP traffic to HTTPS” option on the webserver on which my website is hosted.
I don’t really understand what you mean by your second question.
You can ignore my second question, but basically I just trying to understand if you had configured some sort of local domain name (a hostname for your device).
OK. As I wrote, disabling the “Redirect from incoming HTTP traffic to HTTPS” option on the web server (hosting my website) is necessary for storing the images in gallery.php. That option is undesirable for a number of reasons. That is why I am looking for a possibility to have the image written to the HDD via Wi-Fi and to use a webcam application that sends it to the web server with username and password. That seems to me to be a safer idea than using that aforementioned option. The disadvantage is that you then need a running Windows machine.