RayZ
(RayZ)
6 September 2002 15:44
1
Hi!
I am new to ruby and lack of understanding
– Ruby 1.6.7 & Apache 2.0.40 on win2k –
When i trying to make simple file-uploader i have been confront with a problem
[test.html]
···
attach file:
--------------
then [test.rb]
#!/ruby/bin/ruby
require ‘cgi’
…
someFile, = cgi[‘attach_file’]
data = someFile.read
newFile = File.new(CustomDir + newFilename + extension, “w”)
newFile.write(data)
newFile.close
…
Binary file successfully written to the destination but replaced
"0x0a" symbols with “0x0d 0x0a” (’\r’->’\r\n’)
Please, can anyone explain me - what’s wrong?
P.S. sorry for my bad english. not expirienced yet
Andrew “RayZ” V Rumm
ts1
(ts)
6 September 2002 15:53
2
Well, I know nothing on win32 but try with "wb"
newFile = File.new(CustomDir + newFilename + extension, "w")
newFile = File.new(CustomDir + newFilename + extension, "wb")
do say that you want a binary file (without conversion)
Guy Decoux
RayZ wrote:
I am just guessing (I don’t use MSW), but you may try :
newFile = File.new(CustomDir + newFilename + extension, “wb”)
Note the “wb” open modifier (I would try “bw” also…)
Regards, Christian
RayZ
(RayZ)
6 September 2002 16:04
4
Thanx, Guy
That’s it. It’s works fine with “wb”.
RayZ
(RayZ)
6 September 2002 17:44
5
I am just guessing (I don’t use MSW), but you may try :
newFile = File.new(CustomDir + newFilename + extension, “wb”)
Note the “wb” open modifier (I would try “bw” also…)
Regards, Christian
oke, i am developing my web-server under Windows locally now, and in
future i am planning to use the same ruby sources under Linux
will that “wb” open modifier works with Linux ?
Andrew Rumm.