Reputation: 57
I used AutoIt to automate a single file's upload. Now, I am trying to upload multiple files at once. However, no option is serving the purpose. Here are some of the ways I tried:
Runtime.getRuntime().exec(ARRAY<Filenames>)
Tried passing as one string. Through file system manually this is working fine, but while automating displays as Invalid file name:
Runtime.getRuntime().exec("E:/AutoItScripts/FileUpload.exe" + ""E:\Images\business.jpg" "E:\Images\nature.jpeg"");
Please provide solutions/recommendations/suggestions to resolve the problem.
Upvotes: -1
Views: 951
Reputation: 16
You need to use the required AutoIt script to upload multiple files at once. Refer the below script for multiple file upload.
ControlFocus("Open","","Edit1")
Global $files="",$appendquotes="",$j=2;
IF $cmdLine[0]==1 then
$files=$CmdLine[1]
ElseIf $cmdLine[0] > 1 Then
For $i=1 to $cmdLine[1]
$appendquotes='"' & $CmdLine[$j] & '"';
$files=$files & " " & $appendquotes;
$j=$j+1;
Next
EndIf
ControlSetText('Open','','Edit1',$files)
ControlClick("Open","","Button1")
Use the below java code for multiple file upload
Runtime.getRuntime().exec(config.getAutoITFileUploadScript() + " " + files.length + " " + fileToUpload);
Here, 1st parameter is .exe file path of the script we have given. 2nd parameter is the number of files we are going to pass. 3rd parameter is the path of the files where each file is enclosed in double quotes separated by single space.(i.e)
"D:\karthika\uploadfiles\SampleJPGImage_5mbmb.jpg" "D:\karthika\uploadfiles\SamplePNGImage_5mbmb.png" "D:\karthika\uploadfiles\samplefile.png" "D:\karthika\uploadfiles\SamplePNGImage_3mbmb.png" "D:\karthika\uploadfiles\img16.jpg" "D:\karthika\uploadfiles\artwork.jpg" "D:\karthika\uploadfiles\image2.jpg" "D:\karthika\uploadfiles\image3.jpg" "D:\karthika\uploadfiles\image5.jpg"
Upvotes: 0