Jump to content

web server for upload and download file


name15
 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 ()

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...