# Loading a client text file into a String array

**URL:** <https://discourse.processing.org/t/loading-a-client-text-file-into-a-string-array/3947>\
**Category:** Coding Questions\
**Created:** [September 29, 2018, 1:45am UTC](https://discourse.processing.org/t/loading-a-client-text-file-into-a-string-array/3947 "2018-09-29T01:45:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![desk](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@desk](https://discourse.processing.org/u/desk)\
**Post date:** [September 29, 2018, 1:45am UTC](https://discourse.processing.org/t/loading-a-client-text-file-into-a-string-array/3947/1 "2018-09-29T01:45:24Z")

</div>

I’m a bit new to js. I’m not sure how to load a file. The following code does not work.

```auto
input2 = createFileInput(handleFile2);
input2.position(width/2, height/2); 

function handleFile2(file) 
{
    var lines = loadStrings(file);
}

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 29, 2018, 5:14am UTC](https://discourse.processing.org/t/loading-a-client-text-file-into-a-string-array/3947/2 "2018-09-29T05:14:45Z")

</div>

_lines_ is being declared as a local variable to function **handleFile2()**! 😓  
Instead, declare _lines_ as a global variable outside any functions. 🧐

Here’s an online example sketch using **drop()** instead of **createFileInput()**: 📁  
[p5js.ProcessingTogether.com/sp/pad/export/ro.CYTkHWj9smgw8Q](http://p5js.ProcessingTogether.com/sp/pad/export/ro.CYTkHWj9smgw8Q)

---

<div class="post-metadata">

**Author:** ![desk](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@desk](https://discourse.processing.org/u/desk)\
**Post date:** [September 29, 2018, 6:23am UTC](https://discourse.processing.org/t/loading-a-client-text-file-into-a-string-array/3947/3 "2018-09-29T06:23:23Z")

</div>

Sorry, GoToLoop. I didn’t include the whole sketch. Those are just code fragments. I just found the answer to my question in this video from Shiffman: [Getting Text from User: Loading a Text File - Programming with Text](https://www.youtube.com/watch?v=0Mq2CxspF5s)

Thanks for the response
