retaly Posted October 7, 2012 Share Posted October 7, 2012 (edited) hy guys,possible to check how dir exist on ftp or no??for example: http://www.mysite.com/exampledir/If FileExists("http://www.mysite.com/exampledir/") Then ;tryed some command, it works if i want to find some dir on my pc, but how can i check it on ftp? MsgBox(0, "TEST", "The Dir Already Exist") Else MsgBox(0, "TEST", "The Dir Still Not Exist") EndIf Edited October 7, 2012 by retaly Link to comment Share on other sites More sharing options...
FireFox Posted October 7, 2012 Share Posted October 7, 2012 Hi, If the server you want to check is available from a browser, then It's not a deal of ftp. You have to check for the returned code header from the server, if this one is "404 Not Found" it means that the directory does not exists (OR this error code has been generated by the php function Location). If the server does not exists, _INetGetHeader will return 0. expandcollapse popupGlobal $sHeader = _INetGetHeader("http://www.mysite.com/exampledir/") If StringInStr($sHeader, "404 Not Found") Then MsgBox(0, "TEST", "The Dir Still Not Exist") Else MsgBox(0, "TEST", "The Dir Already Exist") EndIf Func _INetGetHeader($sURL) ;By FireFox (some of it from _INetGetPostSource by GTASpider) Local $iSocket, $sHeader, $sRecv, $iIP, $sHost, $aRegExp, $sHttp1, $iErr, $iSend, $sRecvHeader If $sURL = "" Then Return SetError(1, 0, 0) If StringLeft($sURL, 7) <> "http://" And StringLeft($sURL, 8) <> "https://" Then $sURL = "http://" & $sURL If StringRight($sURL, 1) <> "/" Then $sURL &= "/" $aRegExp = StringRegExp($sURL, "http?://(.*?)/", 3) If @error Then Return SetError(2, 0, 0) $sHost = $aRegExp[0] If $sHost = "" Then Return SetError(3, 0, 0) $sHttp1 = StringTrimLeft($sURL, StringInStr($sURL, "/", -1, 3) - 1) If $sHttp1 = "" Then Return SetError(3, 0, 0) $sHeader = "GET " & $sHttp1 & " HTTP/1.1" & @CRLF & _ "Host: " & $sHost & @CRLF & _ "Connection: close" & @CRLF & _ "User-Agent: AutoIt v3" & @CRLF & @CRLF TCPStartup() ;If not already done $iIP = TCPNameToIP($sHost) If $iIP = "" Or StringInStr($iIP, ".") = 0 Then Return SetError(4, 0, 0) $iSocket = TCPConnect($iIP, 80) If @error Or $iSocket < 0 Then Return SetError(5, 0, 0) $iSend = TCPSend($iSocket, $sHeader) If @error Or $iSend < 1 Then Return SetError(6, 0, 0) While 1 $sRecv = TCPRecv($iSocket, 1024) $iErr = @error If $sRecv <> "" Then $sRecvHeader &= $sRecv If StringInStr($sRecv, @CRLF & @CRLF) Then $sRecvHeader = StringLeft($sRecvHeader, StringInStr($sRecvHeader, @CRLF & @CRLF) - 1) ExitLoop EndIf EndIf If $iErr Then Return SetError(7, 0, 0) WEnd TCPCloseSocket($iSocket) Return $sRecvHeader EndFunc ;==>_INetGetHeader Br, FireFox. Link to comment Share on other sites More sharing options...
retaly Posted October 8, 2012 Author Share Posted October 8, 2012 tyty, but i havent good host for it :/ every host has that php, i mean 404 error. and whats about with file? into dir, example: test.au3 in exampledir, if possible to check file into ftp dir it seems good!, i need dir, or file what i can check, but dir is navaliable now, then i need file :/ Link to comment Share on other sites More sharing options...
caleb41610 Posted October 8, 2012 Share Posted October 8, 2012 tyty, but i havent good host for it :/ every host has that php, i mean 404 error.and whats about with file? into dir, example: test.au3 in exampledir, if possible to check file into ftp dir it seems good!, i need dir, or file what i can check, but dir is navaliable now, then i need file :/If you get a 404 it could mean the folder is not accessible. ( ie you have no permission)Or, it doesn't exist.It could also mean directory browsing is turned off on the web server. You can ask the hosting provider to change this for certain directories, or even do it from the web panel that the hosting company provides.Either way, _INetGetHeader is the way to go like FireFox said. You just need to figure out why you are getting a 404. Multi-Connection TCP Server 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