Imbuter2000 Posted April 23, 2013 Posted April 23, 2013 I would to frequently upload a little (1KB) frequently-updated html file to my web hosting provider (Hostgator > Linux-based-hosting) from an AutoIT script on my Windows PC.I've no experience in uploads. The question is: what upload method/technology would be the fastest? FTP or HTTP?in case of HTTP, what AutoIT function can I use and what do I need to set on the web server to make it accept the upload?
EmptySpace Posted April 23, 2013 Posted April 23, 2013 (edited) I use FTP as my file storage in uploading 1-10kb txt files. I use winhttp to do that but you need php code too Autoit code: #include "WinHttp.au3" Global Const $Adres = "website.com" $subdomain = "uploads/index.php" $filetxt= (@scriptdir & "\test.txt") Global $hOpen = _WinHttpOpen() Global $hConnect = _WinHttpConnect($hOpen, $Adres) Global $sHTM = _WinHttpSimpleFormFill($hConnect, $subdomain, Default, "name:ufile", $filetxt) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) php code: <?php if (isset($_POST['submit']) && !empty($_FILES["ufile"]) && move_uploaded_file($_FILES['ufile']['tmp_name'], "uploads/".time(). "_".basename($_FILES['ufile']['name']))) { echo "Done."; } ?> <html> <head> <title>Upload</title> </head> <body> <form action="index.php" method="post" enctype="multipart/form-data"> Select file: <input name="ufile" type="file" /><br /> <input type="submit" name="submit" value="Upload" /> </form> </body> But also there are way uploading it directly to ftp #include <process.au3> #include <FTPEx.au3> Global $host, $user, $pass ; $host = "ftp.hosting.com" ;can be ip $user = "username" ; FTP Username $pass = "password" ; FTP Password ; Global $file = (@ScriptDir&"/test.txt") Global $open = _FTP_Open('MyFTP Control') ConsoleWrite(@error & "-" & @extended & @CRLF) If $open Then $conn = _FTP_Connect($open, $host, $user, $pass, 0, 21) ConsoleWrite(@error & "-" & @extended & @CRLF) If $conn Then $ftpp = _FTP_FilePut($conn, $file, "/htdocs/uploads/test.txt") ConsoleWrite(@error & "-" & @extended & @CRLF) If $ftpp Then _FTP_Close($open) EndIf EndIf EndIf I think these codes are full of errors but you can make something by yourself Edited April 23, 2013 by EdgarT
Imbuter2000 Posted April 25, 2013 Author Posted April 25, 2013 Interesting EdgarP. With the second (FTP) method it takes about 3 seconds to upload a single tiny 10 bytes long html file. Is your first method (http?) faster?
EmptySpace Posted April 25, 2013 Posted April 25, 2013 I think its slower cos I get my file after more than 3secs. Or maybe hosting fault?
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