Help for a Javascript newbie :) Struggling to work out a file upload issue

Help for a Javascript newbie :) Struggling to work out a file upload issue
0

#1

Hi there,

I have been working on HTML and CSS for a while now with the company i work for and our Javascript dude has just left and they think i can learn as i go on it :sweat_smile:

I’m not doing too bad, but I’ve hit a wall with something that the previous developer did that isn’t working (its a file upload button) and have spent ages trying to rectify it.

I have a screenshot attached of the HTML, CSS and Javascript from playing around in JSFiddle, and at the bottom you can see what the button looks. The upload functionality isn’t working.

I get the feeling that the issue is in the HTML with…

 id="attachLink" onclick="jQuery('#formAttachment :file').click();"

Although correct me if I’m wrong!

I hope someone can help.

Cheers!
Joolz

I think a link might be available here - https://jsfiddle.net/joolz/v5zfnx8f/#&togetherjs=RvbFaH4eC9


#2

I am not sure why you are using jQuery and everything there for what it seems you are trying to do. You can do this with just markup.

<form action="/yourserver/upload" method="post" enctype="multipart/form-data">
  <input type="file" name="upload"/>
  <input type="submit"/>
</form>

See if something along that lines will work, and if not, I can look at your jQuery, it does look like something is wrong there.


#3

Thank you for your reply. I thought the same thing. I wasn’t sure why the jQuery had been placed in there but as the developer is no longer with us i thought others may know. Fortunately, just using simple mark up has sorted it. Thanks so much for your input :slight_smile: