COD3369 Posted January 15, 2014 Share Posted January 15, 2014 (edited) Hello Guys, Well m working on script that will list the files from drive/folder and upload them to a server (ftp). em using Melba23 UDF '?do=embed' frameborder='0' data-embedContent>> #include <Array.au3> #include "RecFileListToArray.au3" #include <File.au3> Local $aArray = _RecFileListToArray("F:", "*.PSD", 1, 1, 0, 2) _FileWriteFromArray( @ScriptDir & "\list.txt" , $aArray, 1) i want to upload file one by one on server by reading the file "list.txt" .. Please help me out with this.. Thank You in advance. o:) Edited January 15, 2014 by verma123 Link to comment Share on other sites More sharing options...
JohnOne Posted January 15, 2014 Share Posted January 15, 2014 Learn how to upload just one file first. Have you tried anything at all from the standard _FTP* functions? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
guinness Posted January 15, 2014 Share Posted January 15, 2014 Also that UDF is included in the stable version as _FileListToArrayRec() UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
COD3369 Posted January 15, 2014 Author Share Posted January 15, 2014 JohnOne yes bro i knw how to upload file using ftp... with Ftp FilePut Function. but don't have any idea how to these one bt one by reading the file Link to comment Share on other sites More sharing options...
JohnOne Posted January 15, 2014 Share Posted January 15, 2014 Get a list of your file names into an array. For $i = 1 To $numberoffiles ;do your code for single file with $aYourFileList[$i] Next AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
gritts Posted January 15, 2014 Share Posted January 15, 2014 Here's my take on your request. I don't have an FTP server I can test against so I hope at least this can give you some ideas. #include <FTPEx.au3> #include <File.au3> Local $FTPServer = 'ftp.server.com' Local $username = 'username' Local $password = 'password' Local $filePath = 'c:\filepath' ;Path to location of files to upload Local $aFileList = _FileListToArray($filePath,"*",1) ;Array list of files in path alone $Open = _FTP_Open('MyFTP Session') $Conn = _FTP_Connect($Open, $FTPServer,$username,$password) ;Add other options as needed For $i = 1 to $aFileList[0] - 1 _FTP_FilePut($Conn,$aFileList[$i],'locationdir') ;tweak for correct destination location Next $FTPc = _FTP_Close($Open) Though there is more hardcoded here than what I would normally do (username, password, path), I hope this can help. Most of the code is variations of what is in the AutoIT help file. I see you also mention reading from a text file, is that a requirement? My approach above just reads the list into an array, eliminating the need for the text file. (Though I can see where you might have a need for the text file) Link to comment Share on other sites More sharing options...
COD3369 Posted January 16, 2014 Author Share Posted January 16, 2014 gritts Bro i tried your code but its not uploading pdf file to my local FTP Server Link to comment Share on other sites More sharing options...
l3ill Posted January 16, 2014 Share Posted January 16, 2014 (edited) sup bro, ;-) is that a pic of your server desktop? then that is a folder named PDF on your desktop? Because your destination location is set to root "/" Other than that I can say what I always say... a lot can go wrong with an FTP transfer. It is usually one or 2 small mistakes in syntax or permissions or connectoins ...etc which means keep tryin bro Bill ...spelling Edited January 16, 2014 by l3ill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
COD3369 Posted January 16, 2014 Author Share Posted January 16, 2014 l3ill it still didnt work if i use " /pdf/ " ??? tell me where m wrong !! ? Link to comment Share on other sites More sharing options...
l3ill Posted January 16, 2014 Share Posted January 16, 2014 I dont know where you are wrong.... Can you upload one file via Ftp FilePut Function? your answer - "Yes Bro" So use that info to upload all of them with the _FileListToArrayRec ( as sugg. bu guinness ) The code from gritts looks like a good start but as he mentioned there is some tweaking involved. Get a small script and one file working then test and play until you get the code to do what you want. Lots of playing and testing invlolved... for instance: one of these '/' in the wrong place and ....no transfer. Show us some code that you have and what it is doing or NOT doing and go from there. good luck! Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
COD3369 Posted January 17, 2014 Author Share Posted January 17, 2014 OKay !! here is what i have done yet !! with help you ! Guys ! #include <FTPEx.au3> Local $sServer = 'server Local $sUsername = 'myuser' Local $sPass = 'pass' Local $hOpen = _FTP_Open('MyFTP Control') Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass) _FTP_FilePut ( $hConn, @ScriptDir & "/hello.pdf" , "/hello.pdf" ,0 ,0 ) with this code above i can upload the single pdf on server. Question : 1. How to Upload multiple files with there orignal names on server. By Reading Files location from array like this: #include <File.au3> #include <Array.au3> #include <RecFileListToArray.au3> Local $sDrives = DriveGetDrive ( "ALL" ) For $d = 1 to $sDrives[0] -1 Next Global $aFileList = _RecFileListToArray( $sDrives[$dvi] , "*.png", 1, 1, 0, 2) For $i = 1 to $aFileList[0] MsgBox ( 16 , "Notice" , "Some Boxes" ) Next If i change the code to this: #include <File.au3> #include <Array.au3> #include "RecFileListToArray.au3" Global $aFileList = _RecFileListToArray( "C:" , "*.png", 1, 1, 0, 2) For $i = 1 to $aFileList[0] FileCopy ( $aFileList[$i] , "C:\Users\Terantula\Desktop" ) Next it works i just removed the this part Local $sDrives = DriveGetDrive ( "ALL" ) For $dvi = 1 to $sDrives[0] _ArrayDisplay ( $sDrives[$dvi] , 1 ) Next so overall with my code i want to upload my all PDF , PSD files to ftp server by searching files in whole pc drives. Hope you guys uderstood what em trying to say ! :sweating: :sweating: Link to comment Share on other sites More sharing options...
michaelslamet Posted January 17, 2014 Share Posted January 17, 2014 That should be easy, especially when you already success upload 1 file to the FTP server. The steps are: 1. Search all the files that match the criterias (*.pdf, *.psd) from all (local?) harddrive. 2. Loop using For..Next and upload those files, eg: For $a = 0 to Ubound($file_list)-1 ; upload here Next For step no 1, I'm a big fan of AZJIO's File Operation UDF found >here Link to comment Share on other sites More sharing options...
COD3369 Posted January 17, 2014 Author Share Posted January 17, 2014 (edited) m not that much hard coder !! please can explain little more cody ? #include <File.au3> #include <Array.au3> #include "RecFileListToArray.au3" Local $sDrives = DriveGetDrive ( "ALL" ) For $dvi = 1 to $sDrives[0] _ArrayDisplay ( $sDrives[$dvi] , 1 ) Next Global $aFileList = _RecFileListToArray( $sDrives[$dvi] , "*.png", 1, 1, 0, 2) For $i = 0 to Ubound($aFileList)-1 _FTP_FilePut ( $hConn, $aFileList[$i] , "" ,0 ,0 ) Next its not working Edited January 17, 2014 by verma123 Link to comment Share on other sites More sharing options...
michaelslamet Posted January 17, 2014 Share Posted January 17, 2014 If you understand for ... next loop and if you spend some time to see AZJIO's File Operation UDF I told you above, you will get it done If you dont, please post your code using that UDF, somebody will help you. Link to comment Share on other sites More sharing options...
JohnOne Posted January 17, 2014 Share Posted January 17, 2014 Forget your FTP stuff for now. Concentrate on making working code that searches your whole computer for the files you want. Post all that you try, along with error checking. Put some real effort in, the more you do that, the more willing assistance you will get. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
COD3369 Posted January 29, 2014 Author Share Posted January 29, 2014 (edited) JohnOne brother Finally its working ... This will search specific file extention in whole system depends on "FIXED" or "ALL" and shows searched files in _ArrayDisplay #include <File.au3> #include <Array.au3> #include "RecFileListToArray.au3" Local $sDrives = DriveGetDrive ( "FIXED" ) for $i = 1 to $sDrives[0] Global $aFileList = _RecFileListToArray( $sDrives[$i] , "*.au3", 1, 1, 0, 2) _ArrayDisplay ( $aFileList ) Next MsgBox ( -1 , "All Done", "Search completed" ) Thanks to all Specially : michaelslamet , JohnOne, l3ill and gritts :sorcerer: :sorcerer: JohnOne Now can we move to Uploading Searched files to FTP Server? Edited January 29, 2014 by verma123 Link to comment Share on other sites More sharing options...
COD3369 Posted January 30, 2014 Author Share Posted January 30, 2014 ???? anyone? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now