Data type of input type file

If I have a form that includes something like:

and I try to get at the file content using:

params[‘file_content’].read

I get:

undefined method `read’ for “filename”:String

where “filename” is the NAME of the file that was assigned to
“file_content” in the input tag.

Apparently Ruby thinks my file is a string and that consequently it
has no ‘read’ method. What am I doing wrong and how can I get at the
actual file content?

Thanks for any input.

    ... doug

On 8 Jul 2008, at 02:55, doug wrote:

undefined method `read’ for “filename”:String

where “filename” is the NAME of the file that was assigned to
“file_content” in the input tag.

Apparently Ruby thinks my file is a string and that consequently it
has no ‘read’ method. What am I doing wrong and how can I get at the
actual file content?

Is your form set to be multipart ?

Fred

Is your form set to be multipart ?

Great thought and it would have really been embarrassing if that had
turned out to be the case; but, it wasn’t. I do have the form set to
multipart with the following attribute to the form tag:

enctype=“multipart/form-data”

I thought this was going to be some really obvious stupid error on my
part like the one you suggested and I thought someone would likely
point it out to me within a few minutes of my post. I guess that’s
not the case. Now, I’m beginning to think that I don’t understand
exactly what it is that comes back in the params hash as a result of
having a tag in the form. If someone could
enlighten me on that, it would be great.

Thanks for the input.

   ... doug

On 8 Jul 2008, at 17:11, doug wrote:

Is your form set to be multipart ?

Great thought and it would have really been embarrassing if that had
turned out to be the case; but, it wasn’t. I do have the form set to
multipart with the following attribute to the form tag:

enctype=“multipart/form-data”

Have you verified in the browser that the expected html is generated?
Have you looked with a packet sniffer to see if the file is being sent
to the server?

Fred

Master Cheung,
I see you mention a ‘packet sniffer’. What is that and how does one
implement one?
I am grateful for any explanation.
Thank you,
Kathleen

On Jul 8, 10:18 am, Frederick C. [email protected]

Thanks for your input and patience, Fred.

As is usually the case in these types of situations, the problem
turned out to be a factor that I didn’t deem as being relevant. That
factor is that access is being controlled by sessions. The brief
explanation is that I made my form by using straight HTML rather than
the Rails helpers. Without going into all of the gory details, one
needs to use the Rails helpers in this case. I now have it working.
Thanks for the input.

        ... doug

On 9 Jul 2008, at 14:59, [email protected] wrote:

Master Cheung,
I see you mention a ‘packet sniffer’. What is that and how does one
implement one?

It’s a piece of software that dumps/displays all the packets going
through your machine (usually with the ability to filter based on a
set of conditions so that you can narrow it down to what you’re trying
to observe)
Eg tcpdump, wireshark (formally ethereal) etc…
On unixy platforms, there are a set of ruby bindings for libpcap (the
library that tcpdump uses) if you feel like doing your packet sniffing
from ruby.

Slightly different, but also interesting are things like

and Fiddler | Web Debugging Proxy and Troubleshooting Solutions These are http proxies that
let you inspect all the traffic being passed through.

Fred