1

So I have a webpage and am using the <input type="file"> tag. The user should be able to select a file (not multiple), then I have to check if it is a .csv and set the data to a JavaScript variable (string) to further process it. The JavaScript-Code has to be in a separate file, so I can't put the code in <script> tags in my HTML file but rather inside a function called after a button press or something.

I tried php and ajax, with no success. I have no experience with php, so I don't really know what went wrong, but my php code just get's printed on the page:

page after php

HTML:

<form action="upload.php" method="POST" enctype="multipart/form-data">
    <input type="file" name="file">
    <button type="submit" name="submit">UPLOAD</button>
</form>

As for the ajax, I used several posts on Stack Overflow with such as:

Link 1

Link 2

Link 3

I would prefer no plug-ins if possible.

Thanks!

brombeer
  • 8,716
  • 5
  • 21
  • 27
Johannes
  • 11
  • 2

0 Answers0