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!

2
  • 2
    Do you have a web server running? Does it have PHP installed/enabled? Commented May 30, 2020 at 17:03
  • No, I don't. Will try that. Does that also explain why ajax isn't working? Commented May 30, 2020 at 19:14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.