Upload Button

Hi guy’s, i would like to put an upload button on my webside like that the use’s can put they CV to send to us.
Sorry for my english :confused:

Thx

Hey Amir,

Welcome to the Wix Code forums.

Take a look at the article How to Use the Upload Button with Code . This will show you what you need.

Have fun,

Yisrael

1 Like

Ok, thank you, i will try. :smiley:

I have try and when i put this JS Code :

export function button1_click_1(event, $w) {
 //Add your code for this event here: 
 if($w("#uploadButton1").value.length > 0) {
    $w("#text1").text = `Uploading ${$w("#uploadButton1").value[0].name}`;
    $w("#uploadButton1").startUpload()
      .then( (uploadedFile) => {
        $w("#text1").text = "Upload successful";
        $w("#image1").src = uploadedFile.url;
      })
      .catch( (uploadError) => {
        $w("#text1").text = "File upload error";
        console.log(`Error: ${uploadError.errorCode}`);
        console.log(uploadError.errorDescription);
      });
  } 
 else {
    $w("#text1").text = "Please choose a file to upload.";
  }


}

they show me this error : is not a valid selector for :

("#uploadButton1")
("#text1")
("#uploadButton1")
("#uploadButton1")
("#text1")
("#image1")
("#text1")
("#text1")

I don’t understand why

You need components with those IDs on your web page. The error is telling you that those components are missing, or have different names.

I have no different name :


Sorry but i don’t know JS

Please post the URL of your site. Only authorized Wix personnel can get access to your site in the editor.

go to Contact page

What page?

Contact page

But don’t publish the webside :slight_smile:

The code will not work with a Contact Form component. You need a page that has all of the components as you listed above. You will need to carefully follow the article How to Use the Upload Button with Code in order to properly build the form.

1 Like

But i have put a button outside the contact form. The Blue button

You need more than just a button. You need all of the components that are used in the Javascript code, and the components must have the IDs that are used in the code.

ok, thank you :slight_smile:
i will try again

Amir

Hello! I was wondering how I would be able use this form to send an email with the attached file?I would really appreciate some help as I am quite new to this haha

I’m having the same issue. Would you be able to help me? I’m trying to allow my customers to upload images for their custom orders . I need the buttons on the product page. I had the same issue with the JavaScript

What “same issue” are you having? Please add your own issue into a new post instead of bumping up an old post.

Explain what you are trying to, what works, and what doesn’t. You said you had an issue with the Javascript, so add any code in a code block as stated in the Forum Guidelines so we can help.

This is an old post and is being closed.