Upload files to webpage

I want to create a workflow which will pick a set of files from a folder and upload it to a webpage. workflow should try to upload each file twice and in case it fails it should pick next file to upload.

And the problem you’re facing is…?

@vidyasak,

You got the problem statement. Give it a try like this.

  1. Use For Each File in Folder - you can add filters to filter specific files.
  2. Inside this Add Retry Scope. Set it’s properties as per your requiremnet.
  • NumberOfRetries - The number of times that the sequence is to be retried.
  • RetryInterval - Specifies the amount of time between each retry.
  1. Inside Retry Scope add your logic to upload file to webpage.

That’s it!

Thanks,
Ashok :slight_smile:

What would be the condition in the retry here.?

Use Activities - Check True (uipath.com) activity.

Sample code:

Thanks,
Ashok :slight_smile:

Thanks sir :slight_smile: Solution worked!!!

1 Like

Found an alternate way:

  1. Initialize Variables

    • Define input variables for the source folder path and the webpage URL
    • Define a list/queue data structure to store the files to be uploaded
    • Define a counter variable to keep track of the number of upload attempts for each file
  2. Get Files from Source Folder

    • Use the “GetFiles” activity to retrieve a list of files from the specified source folder
    • Add the retrieved files to the list/queue data structure
  3. Loop Through Files

    • Use a “For Each” loop to iterate through the list/queue of files
  4. Upload File

    • Within the loop, use a “Try Catch” block to handle exceptions during the upload process
    • In the “Try” block:
      • Use the “AttachBrowser” activity to attach to the target webpage
      • Locate and interact with the necessary web elements (e.g., file upload input, submit button) using UI Explorers or selectors
      • Upload the current file using the appropriate web interaction activities
  5. Handle Upload Failure

    • In the “Catch” block:
      • Increment the counter variable for the current file
      • Check if the counter variable is less than or equal to 2 (maximum allowed attempts)
      • If the counter is less than or equal to 2, re-add the current file to the end of the list/queue for another upload attempt
      • If the counter exceeds 2, log an error message and move to the next file
  6. End Loop

    • After the loop completes, handle any remaining files in the list/queue (if applicable)
  7. Cleanup

    • Close the browser instance
    • Log a success message or perform any additional cleanup tasks
  8. Error Handling

    • Use a “Try Catch” block to handle exceptions at the workflow level
    • In the “Catch” block, log any errors and perform necessary error handling procedures
  9. Workflow Output

    • Optionally, provide output variables or logs to report the status of the file uploads (e.g., number of successful uploads, failed uploads, etc.)

Note: This is a high-level outline, and you may need to adjust or add steps based on your specific requirements, such as authentication, handling dynamic web elements, or additional error handling scenarios.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.