gapsna
Posts: 4
Joined: Tue Jun 23, 2015 12:17 pm

How to upload a file to the RasPi web server?

Fri Jun 26, 2015 11:56 am

Hello,

I'm working on a little project at my company. I created a web server on the RasPi using apache to put a couple of plots as .png images generated on the RasPi, but I also need to upload a log file (just some KiB) so it can be downloaded from other computers that visit the IP address of the Pi. Is that somehow possible?

Thank you very much for your help. I'm pretty noob with the raspi, linux and servers :S

gkreidl
Posts: 6222
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: How to upload a file to the RasPi web server?

Fri Jun 26, 2015 12:17 pm

You need some kind of server side scripting support (PHP, Python, bash cgi script) that can handle a POST command. Then create an upload page with a form to enter the file path. The form calls the CGI (or whatever kind of scripting you are using) which handles the uploaded file.

I'm sure you'll find a lot of working solutions by searching the net.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

gapsna
Posts: 4
Joined: Tue Jun 23, 2015 12:17 pm

Re: How to upload a file to the RasPi web server?

Fri Jun 26, 2015 12:32 pm

Hi, thanks for your answer, I just found an easy way to do it i html:

<a href='test.pdf'>(Test.pdf)</a>

and just leave the file in the server folder ^^

gkreidl
Posts: 6222
Joined: Thu Jan 26, 2012 1:07 pm
Location: Germany

Re: How to upload a file to the RasPi web server?

Fri Jun 26, 2015 12:38 pm

gapsna wrote:Hi, thanks for your answer, I just found an easy way to do it i html:

<a href='test.pdf'>(Test.pdf)</a>

and just leave the file in the server folder ^^
That's for downloading the file, but you were asking about uploading it to your server.
Minimal Kiosk Browser (kweb)
Slim, fast webkit browser with support for audio+video+playlists+youtube+pdf+download
Optional fullscreen kiosk mode and command interface for embedded applications
Includes omxplayerGUI, an X front end for omxplayer

gapsna
Posts: 4
Joined: Tue Jun 23, 2015 12:17 pm

Re: How to upload a file to the RasPi web server?

Fri Jun 26, 2015 2:34 pm

gkreidl wrote:
gapsna wrote:Hi, thanks for your answer, I just found an easy way to do it i html:

<a href='test.pdf'>(Test.pdf)</a>

and just leave the file in the server folder ^^
That's for downloading the file, but you were asking about uploading it to your server.
you are right. I wrote the wrong answer, it was for downloading something from the server. I apologize.

if I may ask you an other question, the python script that creates the log file, needs to delete the first line after a certain number of lines has been reached (so the file doesn't keep growing for ever), do you know how to do this?

The log file looks like this:

26.06.2015 14:21 21 73
26.06.2015 14:22 23 73
26.06.2015 14:23 23 70
26.06.2015 14:24 24 75
26.06.2015 14:25 24 74
26.06.2015 14:26 25 72
26.06.2015 14:27 22 72
26.06.2015 14:28 25 73
26.06.2015 14:29 22 74
26.06.2015 14:30 25 72
26.06.2015 14:31 23 74
26.06.2015 14:32 23 75
26.06.2015 14:33 22 71
26.06.2015 14:34 20 74
26.06.2015 14:35 25 75
26.06.2015 14:36 21 71
26.06.2015 14:37 21 74
26.06.2015 14:38 23 73
26.06.2015 14:39 22 74
...
(the values are random at the moment)
It saves the measure from a sensor every minute, and for example after a month of data, ie. after there are 43200 lines, it should delete the first line and then create the new one after the current last line.

Thank you for your help.


Return to “Beginners”