Uploading file

Nothing to happen. Can you help me out.
I wanna upload image file from my computer.

Usually after uploading a file you need to click something or trigger a specific js function that the site activates on a successful upload. If that doesn’t work, I could add something like this c# - How do I upload a file with Puppeteer Sharp? - Stack Overflow please let me know or open an issue if you want me to add it.

Capture
I wanna UPload file from my computer.
I do this in puppeteer but Nothing to happen.
Can you help me out.


You have to upload a file that is on your disk, you cannot upload from URL xD

I did it as succesfull with this path
C:\Pictures\BlueStacks\ok.png
But If I have alot of images in folder I wanna Upload all of files in this folder. How can I do it.
Maybe Path as C:\Pictures\BlueStacks\

FOREACH file IN System.IO.Directory.GetFiles("PATH_TO_YOUR_DIR_HERE")
// Upload block here, use the 'file' variable
END
1 Like

I tried this but NOt successfull.

Or I tried that not successfull too.
FOREACH file IN System.IO.Directory.GetFiles(“My Path”)
// Upload block here, use the ‘file’ variable
END

Thank you Ruri.

Man… the syntax is completely wrong…
Also you have to escape \ like this \\

FOREACH file IN System.IO.Directory.GetFiles("C:\\Users\\Pictures\\Bluestacks")
BLOCK:PuppeteerUploadFile
  findBy = Selector
  identifier = "input[name=\"file\"]"
  filePath = @file
ENDBLOCK
END

Do you understand now?

I got this error

Maybe the regex I wrote for the foreach doesn’t capture everything properly but only variables, I don’t remember how I did it, anyways try this

foreach (var file in System.IO.Directory.GetFiles("C:\\Users\\Pictures\\Bluestacks"))
{
BLOCK:PuppeteerUploadFile
  findBy = Selector
  identifier = "input[name=\"file\"]"
  filePath = @file
ENDBLOCK
}
2 Likes

Thank you But I got this error below

Upload image replace by itself

please help me out, @Ruri

Maybe you have to trigger some js code after uploading each individual image so it gets added to the others, idk the site’s code, but the block itself works

When I uploaded the first image, Website show more place (Yellow Camera Button) to upload another file.
Capture

Code of the first image:
<div class="thumbnail FqEXhcfmBAIO7XHZs22Da" style="background-image: url(&quot;https://cdn./raw/Dpg9GVd3YgF4za71h6cVfYeFssbDeYHye6i8jEOIuZc/preset:raw/plain/e6051c5d34ccb4d7a01fc98a1ec138ee-2711037095347836170.jpg&quot;);"><button type="button" class="btn btn-close btn-xs"><i class="fa fa-times"></i></button></div>

Yelow camera button code:

<div class="_3wLdyQ1JXeAenU3yteGpQI _1vC0rhL9xeJOYM0fMD3igP"><button type="button" class="btn btn-brand btn-large"><img alt="https://static/storage/ch-icons/svg/camera-icon.svg" role="presentation" src="https://static./storage/ch-icons/svg/camera-icon.svg"><i>+</i></button></div>

Can You help edit code.

Now I understand, yeah, I will change it so that you can upload multiple files at once :slight_smile:

1 Like

Thank you Ruri, Hopfully You can make it work Sir.

1 Like

I just pushed a commit with support for uploading multiple files. The block changed so you need to delete it and remake it using the new one.
This is the new code you will be able to use in v0.1.6 (update will be today)

BLOCK:GetFilesInFolder
  path = "C:\\Users\\Pictures\\Bluestacks"
  => VAR @files
ENDBLOCK

BLOCK:PuppeteerUploadFiles
  findBy = Selector
  identifier = "input[name=\"file\"]"
  filePaths = @files
ENDBLOCK
1 Like

Thank you, I will wait fỏ 0.1.6. Great job.