[Tutor] Ftp question

Remco Gerlich scarblac@pino.selwerd.nl
Mon, 14 May 2001 13:11:35 +0200


On  0, Sharriff Aina <NHYTRO@compuserve.com> wrote:
> 1. using the ftplib to upload images onto a remote server per CGI, I
> noticed that after a fie upload, the connection closes, is there a way to
> keep this connection open till I finish iterating thru a a list of files to
> upload? I found nothing addressing this at Python.org.

It shouldn't do that, as far as I know. It would help if you could post a
snippet of your code. Can you test the program from the command line instead
of in CGI? Does it make a difference? (that's just blind guesswork)

> 2. Some files donŽt get completely transfered, only gibberish is written. I
> noticed this happens to bigger files. I increased the Buffer to 8192 but
> that didŽnt help, is there a way to address this problem? IŽll be uploading
> very big image files.

Hmm. Are you on Windows but opening the files in ASCII form?
Use open(filename, "rb"), not just "r".

By default, files are opened as ASCII, and on Windows, a ^Z byte means end
of file. In a binary file like an image, that byte may occur anywhere.
Opening the file in binary mode works.

-- 
Remco Gerlich