Jump to content
Sign in to follow this  
name15

web server for upload and download file

Recommended Posts

name15

i try too hard to make script for web server for upload and download file but

the file always Have not complete read and write header of file so it not work

if there is any example do that jop

$file = FileOpen("C:\Documents and Settings\sp3\My Documents\10.jpg", 16)
While 1
$line = FileReadLine($file)
If $line = @error Then ExitLoop
$data = $data&$line
WEnd
TCPSend($socet,$data)

While 1
$dre = TCPRecv($socet,$port)
 If @error Then ExitLoop
$data = $data&$dre
WEnd
$file = FileOpen("C:\Documents and Settings\sp3\My Documents\12.jpg", 16)
While 1
$line = FileWriteLine($file)
If $line = @error Then ExitLoop
$data = $data&$line
WEnd

Share this post


Link to post
Share on other sites
PsaltyDS

1. This is wrong: "If $line = @error Then ExitLoop"

The macro @error is set to a value, it is not returned from the function.

Just use: "If @error Then ExitLoop"

2. Don't use FileReadLine() and FileWriteLine() with a binary file. Use plain FileRead() and FileWrite() instead, specifying how many bytes to read in a block (i.e. 1024 bytes at a time).

3. Since you are reading the entire file, there is actually no need for a loop anyway:

$file = FileOpen("C:\Documents and Settings\sp3\My Documents\10.jpg", 16)
$data = FileRead($file)
FileClose($file)
TCPSend($socet,$data)
Same thing applies to the FileWrite() at the other end.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
name15

ok you right but i try simple chat program so when user whant send file that make

client slower so i try to make simple web to upload and download it like file shear

i well do that but that idea it more easy for programing in server well be TCPSend () and client will be InetGet ()

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×