How I can upload some file on my automation

Hi everyone, I need your help if is possible, on a tecnical doubt I have on my automation, I wrote the code below and the browser opened the window to choose the file I wants to upload:

find(:xpath, ‘//span[@id=“page:idFormUpload:j_id138:0:reRenderUploadRow”]’).click
But when I use the code below the automation get a error, the path of the file is “C:\Users\jsporn\Pictures\imagemTeste_robo.png”, I don´t know if the sintax of this command are right or not, can anyone help me?

attach_file Rails.root.join(“file”,‘C:\Users\jsporn\Pictures\imagemTeste_robo.png’)
Or this code below:

attach_file(“attachments”, ‘C:/hughes/imagem_robo_CPF/imagemTeste_robo.png’)

Thanks