Reputation: 65
Im currently working on a web application, where i need to be able to take a picture in a browser using a mobile device. I'am currently able to upload this picture to my storage on googlecloud, but i am having some troubles with the URL of said picture. The URL of the picture is defined in an action(HTML attribute). And im struggling to see how this action field can be dynamic. It seems i cant put in the variable name for my URL in the action field.
Is there any other way to do this? Im sorry in advance for my bad english.
<form id="BilleddeUpload" action="url" method="POST" enctype="multipart/form-data">
<input type="file" accept="/*" name="file">
<button>Submit</button>
</form>
<script>
function gogogoogle(){
var billedenavn = document.getElementById("BilledeUpload");
var url = "https://storage.googleapis.com/notgonnaputreallinkhere/"
+ prompt("Insert picture name here.");
billedenavn.action=url;
}
</script>
<p>Billede på google cloud </p>
<button onclick="gogogoogle()">
Hvad skal den hedde????
</button>
Upvotes: 3
Views: 121
Reputation: 134
their is some syntax error.
put function
[and it's body] into script
tag,
and change form
id
from BilleddeUpload
to BilledeUpload
.
Upvotes: 0
Reputation: 12707
You already have defined a variable to hold a reference to the form billedenavn
.
This line
var billedenavn = document.getElementById("BilledeUpload")
and a few lines later you wrote
document.getElementById("BilledeUpload").action = url;
which contains a typo in the form ID. But why not directly write:
billedenavn.action = url;
Upvotes: 1