# How can I open a local file?

**URL:** <https://www.ruby-forum.com/t/how-can-i-open-a-local-file/112483>\
**Category:** Ruby\
**Created:** [August 20, 2007, 2:21am UTC](https://www.ruby-forum.com/t/how-can-i-open-a-local-file/112483 "2007-08-20T02:21:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhan\_feng\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a88e57/32.png) [@Zhan\_feng\_W](https://www.ruby-forum.com/u/Zhan_feng_W)\
**Post date:** [August 20, 2007, 2:21am UTC](https://www.ruby-forum.com/t/how-can-i-open-a-local-file/112483/1 "2007-08-20T02:21:03Z")

</div>

Hi,friends,  
how can I get the path of a local file, so that I can open and read the  
file?  
in my webpage I have following:

```
Select A File:
```

And e.g. I will get the fname=“/home/wym/exdir/ruby/file1.rb”, here the  
path if local, how can I get the IP of the local path if my  
ip=“[http://127.0.0.1](http://127.0.0.1)”?

Thanks

---

<div class="post-metadata">

**Author:** ![Zhan\_feng\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/a88e57/32.png) [@Zhan\_feng\_W](https://www.ruby-forum.com/u/Zhan_feng_W)\
**Post date:** [August 20, 2007, 4:24am UTC](https://www.ruby-forum.com/t/how-can-i-open-a-local-file/112483/2 "2007-08-20T04:24:31Z")

</div>

quoth the Zhan feng Wang:

> And e.g. I will get the fname=“/home/wym/exdir/ruby/file1.rb”, here the  
> path if local, how can I get the IP of the local path if my  
> ip=“[http://127.0.0.1](http://127.0.0.1)”?
> 
> Thanks

Hi.

I guess you may want to browse the CGI docs. [0], [1]. If that doesn’t  
help  
then perhaps you need to formulate your question a bit clearer. I, for  
one,  
am not sure what you mean by “get the IP of the local path”.

[0] [http://www.ruby-doc.org/core/classes/CGI.html](http://www.ruby-doc.org/core/classes/CGI.html)  
[1]  
[http://www.whytheluckystiff.net/ruby/pickaxe/html/lib\_network.html#S3](http://www.whytheluckystiff.net/ruby/pickaxe/html/lib_network.html#S3)

-d
