| View previous topic :: View next topic |
| Author |
Message |
youresam
Joined: 06 Nov 2005 Posts: 87
|
Posted: Fri Dec 16, 2005 8:11 am Post subject: Help: Downloading images |
|
|
Can anyone help me out with downloading images from the Wlan? I saw the HTTPD code and it looks a bit complicated to SEND, but to recieve it could require some more advanced coding..
If anyone has/can do this, please tell.
Thanks. |
|
| Back to top |
|
 |
swordman
Joined: 27 Dec 2005 Posts: 27
|
Posted: Wed Dec 28, 2005 1:22 am Post subject: |
|
|
Hi, if you want to retive a file from the net, you need to use the HTTP protocol (or the FTP)
Simply send to the server a string like the following:
GET <path&filename> HTTP/1.1\r\n\r\n
Then wait on line end recive the data.
NOTE: I think that on PSP are needed more then
socket:recive() to obtain alla the data. |
|
| Back to top |
|
 |
youresam
Joined: 06 Nov 2005 Posts: 87
|
Posted: Wed Dec 28, 2005 2:49 am Post subject: |
|
|
| Well, I already know how to retrieve a file, but Im saying how to build it into a PNG file. I have made a program that copies all the lines from a PNG and pastes it into a new PNG, but the PNG isnt working even though if I open it in notepad, it had the same characters. I need to download a PNG and save it. |
|
| Back to top |
|
 |
ShUr1k3n
Joined: 16 Oct 2005 Posts: 42
|
Posted: Wed Dec 28, 2005 6:22 am Post subject: binary mode |
|
|
U must READ and WRITE the file in Binary Mode...
If u copy the characters the file will not be the same... Because some characters are not displayed...ETC...
In VB i use: Open "filename.extension" For Binary As #1
well... Google for it and u will find a lot of Stuff...
I hope that helps... |
|
| Back to top |
|
 |
youresam
Joined: 06 Nov 2005 Posts: 87
|
Posted: Wed Dec 28, 2005 6:43 am Post subject: |
|
|
Thanks a lot!
I found the lua.org booklet thing, and it said that you can inclue an optional 'b' for binary mode. Testing right now, will post results...
EDIT
Nope. Doesnt work. Same results when I make it read + write binary, read binary, or just write binary. Heres my code:
| Code: | loadtable = ""
function load()
file = io.open("2.png", "rb")
if file then
for line in file:lines() do
loadtable = loadtable..line
end
file:close()
end
end
function save()
file = io.open("3.png", "wb")
if file then
file:write(loadtable)
file:close()
end
end
load()
save() |
|
|
| Back to top |
|
 |
Shine
Joined: 03 Dec 2004 Posts: 728 Location: Germany
|
Posted: Wed Dec 28, 2005 10:32 am Post subject: |
|
|
| lines() translates newline characters, try read the whole file with read("a"). |
|
| Back to top |
|
 |
youresam
Joined: 06 Nov 2005 Posts: 87
|
Posted: Wed Dec 28, 2005 1:09 pm Post subject: |
|
|
Ok...
So, how would I do that? I havent experimented with that abtribute yet... I mean, how would I read it or write it if I cant use variables...
Some sample code would be appreciated.
(P.S., shine, have you tried out my LUA OS yet?) |
|
| Back to top |
|
 |
Slopey
Joined: 31 Jul 2005 Posts: 24
|
Posted: Fri Dec 30, 2005 11:05 pm Post subject: |
|
|
use
local data = file:read("*a")
it'll load the entire file in binary into the data variable.
There's more info at http://www.lua.org/pil/21.2.2.html on the lua site proper. |
|
| Back to top |
|
 |
|