# Copying the file in local hard drive to the text field in th

**URL:** <https://www.ruby-forum.com/t/copying-the-file-in-local-hard-drive-to-the-text-field-in-th/72192>\
**Category:** Ruby\
**Created:** [October 15, 2006, 10:15am UTC](https://www.ruby-forum.com/t/copying-the-file-in-local-hard-drive-to-the-text-field-in-th/72192 "2006-10-15T10:15:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@michael](https://www.ruby-forum.com/u/michael)\
**Post date:** [October 15, 2006, 10:15am UTC](https://www.ruby-forum.com/t/copying-the-file-in-local-hard-drive-to-the-text-field-in-th/72192/1 "2006-10-15T10:15:45Z")

</div>

In my previous inquiry, I have received the below suggestion; I was  
inquiring how I can copy a file in my hard drive to the text field in  
the web.

Yes, below code works!!! but each file I need to upload is quite  
lengthy, and I have many hundreds of them.

When I run the code below, WATIR is reading the file in my hard drive a  
character by character into the text field in the web; it simply takes  
too long.

Is there anyway I can copy the file in my hard drive in its entirety  
all at once, and paste it to the text field in the web at once?? That  
way I do not have to wait till the code reads a character by  
character… and the job will be done much faster…

any suggestion or help will be deeply appreciated.

thanks.

# m.

Well, what you’re doing is just taking the contents of the variable  
$Path and setting it to the text field. You’ll actually need to open  
and read the file. For example…

ie.text\_field(:name, “html\_text”).set(File.new($Path).read)

That should do it.

M.T.

---

<div class="post-metadata">

**Author:** ![michael](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4bbf92/32.png) [@michael](https://www.ruby-forum.com/u/michael)\
**Post date:** [October 15, 2006, 12:05pm UTC](https://www.ruby-forum.com/t/copying-the-file-in-local-hard-drive-to-the-text-field-in-th/72192/2 "2006-10-15T12:05:55Z")

</div>

ie.text\_field(:name, “html\_text”).value = File.new($Path).read
