This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
DannySMc's profile picture

How to upload files to a web server using php?

Started by DannySMc, 14 October 2014 - 07:54 AM
DannySMc #1
Posted 14 October 2014 - 09:54 AM
I want to be able to upload files to a web server, so they are viewable online? I want users to be able to send a file using a predefined program that will store it online? I need to be able to:
+ Upload the file -> Serialize the data? then unserialize? or I don't know? It has to be the raw file?
+ Download the file -> This is used to download the raw file?
+ Delete a file -> This is used for users to delete files?
+ Update a file -> I want to be able to update a file too, so If i have a table file, that is stored, I wanna be able to download a copy, add changes, then send it back and it will replace the old one?

I have no idea how to do this.
Bomb Bloke #2
Posted 14 October 2014 - 10:26 AM
At least within ComputerCraft, you've only got text-based http connections available. That means the remote server your dealing with will generally need to be running PHP scripts which are equipped to deal with your code.

Pastebin is one example of a web server that's been configured to accept "files" (or text documents, at least) using the http protocol. Thus the simple answer is "use pastebin, but if you want to handle non-text files, serialise using base64 conversion first".
DannySMc #3
Posted 14 October 2014 - 11:01 AM
At least within ComputerCraft, you've only got text-based http connections available. That means the remote server your dealing with will generally need to be running PHP scripts which are equipped to deal with your code.

Pastebin is one example of a web server that's been configured to accept "files" (or text documents, at least) using the http protocol. Thus the simple answer is "use pastebin, but if you want to handle non-text files, serialise using base64 conversion first".

Yeah but how? Could you show me an example or something of the PHP needed as well as the Lua? I have a web server with php and databases? just need to upload text files? raw ones anyway?