How to make a button that goes to a link

Hello!
In html I made a custom button that asks for a file once that is clicked. I’m trying to figure out how to set it up so when a user chooses a file, it goes to another page.

Also how do I make it so it can tell if the file is a image or not?
I’m new to html btw

Hi Someone!

First, it would be helpful if you have a Glitch project to share it here so we can take a look. But I’ll give some general thoughts…

the simplest thing that can possibly do something

I guess you have an input type="file" (like this)

If you want to make this go to another page, you can wrap it in a form element, set the action to another page, and add a Submit button. For example:

a.htm

<label for="avatar">Choose a profile picture:</label>

<form action="b.htm" method="GET">
  <input type="file"
       id="avatar" name="avatar"
       accept="image/png, image/jpeg">
  <input type="submit">
</form>

b.htm

<p>Got it</p>
  • The way we set up the file input only allows image files. Maybe that helps you?
  • Page B will receive the filename in the query string but not the file content (i.e. you will arrive at /b.htm?avatar=my-image.png)

but I want to store/analyse/do something to the image

In this case you need to move onto something with a backend – on Glitch we usually use Express for this (start a project with ~hello-express)

In Express you can set up a route to accept the form data, point the form at it, and change the method to method="POST"

If that’s the way you want to go, let us know what you’re trying to achieve and we can be more specific!

Hope this helps :slight_smile:

Hi, Me and my friend are trying to make an art site where you can upload art and share it to some people. Here is the main page html so far. [( every time I tried to put it here it kept cutting )]
(Pastebin.com - Burn After Read paste)

Anyways what I’m trying to do is make it so the user can upload an image then it will go to another page to confirm they want to upload it.

Also do you know where else I can store photos? I don’t want to store it strait from glitch because I don’t have pro and I don’t want to run out of space.

personally I convert images to .svg then save the code to MongoDB. It’s really clunky but it works for what I need it to